1.

Solve : VBScript Functions?

Answer» Vb Script was made by Microsoft to make windows scripting easier. It still is a good choice to help with some things that a re hard to do is just batch alone.
Here is a page teat gives the basic functions in VBScipt.
http://www.w3schools.com/VBscript/vbscript_ref_functions.asp#string
If you check out the string functions you will find a nice library of clever things yhou can do with strings.
http://www.w3schools.com/VBscript/vbscript_ref_functions.asp#string
Upper and lower case, left string, right string and even reverse string and others. If batch is giving you a HEADACHE. just have the batch filed prepare a skhort VBS file and invoke the Vb script t from inside your batch.  have it return the valoues to the batch file.
Andy body have a piratical  example? 
Wheel are circular in shape and help vehicles, shopping carts, skates, etc, progress along horizontal surfaces! But they aren't donuts! Oh no sir!!!! Anybody got any piratical examples? Also: in other news fr0m 1999, Boris Yeltsin resigns, Internet Explorer version 5 released and so is the initial release of Napster...



Having re-read the above post, which I wrote after several glasses of wine, I SEE it as unkind and unhelpful. Furthermore, I actually agree very much with what it says. I apologise and offer below what will (hopefully) mitigate the sin.

Visual Basic Script is a very useful language. It is a useful and logical next STEP for scripters after batch language ("DOS") on Windows 32/64 bit. Just about anything you want to do in batch you can do more easily and in clearer code in VBscript. Also you can do lots of network and system stuff, and manipulate Microsoft Office apps as well.

You can do things which are impossible or cumbersome in batch, e.g. non-integer arithmetic and/or numbers bigger than plus or minus  2,147,483,647. Also just one example at random, date and time stuff is easy to code.

A couple of example date functions are Now() and Day(). The Now function takes no arguments, and returns the CURRENT date and time as a string, e.g. for me right now Now returns this string: "07/02/2015 09:34:25" (date and time as in local system format settings). The Day function takes a valid date string or value and returns the day of the month of that date as a number from 1 to 31. You can nest them so Day(Now) returns 7 because today is February 7th, and there are other date functions such as Month(), MonthName, Year(), Weekday(), WeekdayName().

Examples:

Month(Now) returns 2 because February is the 2nd month of the year.
MonthName(Month(Now)) returns "February".
WeekDayName(Day(Now)) returns "Saturday"

These are just a few of the functions in VBSscript.

Later I will show some ways of the using them from batch, although I really feel that if you want to do this, why not go the whole way and swithc languages. Sometimes we have to modify an existing batch script.

One very useful function to use with batch scripts is the VBScript Eval() function, which I shall mention...
Quote from: Salmon Trout on February 07, 2015, 02:35:02 AM
Furthermore, I actually agree very much with what it says.

I meant, I agree very much with what Geek-9PM says in his original post about Visual Basic Script.

Thanks, glad you got it.
Fro many it is easier to build a bridge from batch to VB Script or some other tool. The may be because there is a lot of documentation and tutorials on VB Script and other scripts. And batch can be convoluted.
This VBS advantage has been covered well in Stack Overflow:
http://www.cnet.com/topics/networking/best-networking-devices/
Quote
I have a VBScript file which I am trying to call from a Batch file. The following code I coped to a notepad and saved as MyScript.vbs
The author has bit of a problem invoking the vbs from batch, but they found the answer. Stackoverflow is a good resource.

Another:
http://stackoverflow.com/questions/6216285/how-to-run-a-vbs-from-a-bat
Quote

Created an extensive batch script program to handle some automated file management and printing and I need to call a vbs file for its sendkeys operation. Is there a way to accomplish this without freezing the program?
I've tried START /WAIT my.vbs and the script freezes when it enters the .vbs
Anyone have other methods or switches you would recommend?
Again, he got some help. Using the right incantation, one can pass parameters from batch to a vbs and the vbs can return values in a file.

For script languages that can not get  parameters on the command line,  one can always use redirection to send and receive values. I did this once with the old MS QBASIC interpreter.  That version of QBASIC did not know how to read the COMMAND string and I had to put values into a temporary file.  Got it to work!

Like to remind all that you can CALL one batch from another. The allows one to 'hide' some details of how something convoluted is done. The convention I use is to prefix child files with the underscore char.
Like this:
BIGJOB.BAT
_BIG1.BAT
_BIG2.BAT
OTHER.BAT
_OTH1.BAT
_OTH2.BAT

In the above, the underscores identify files those called from the parent files. 


Discussion

No Comment Found