Monday, May 16, 2016

Learn VB Script Part 1

My First program in VB Script


To run scripts using the Windows-based script host (Wscript.exe) Browse to the folder containing the script you want to run and double-click it. 




From a command prompt window

At the command prompt, type the name of the Windows Host executable file (Wscript.exe), followed by a space, then the full path name of the script you want to run. Be sure to include the file name extension of the script file. Press Enter to start the script.






Note
Windows scripts are files with the following file name extensions: .wsf, .vbs, .js.
If you double-click a script file whose extension has not been associated with Wscript.exe, the Open With dialog box appears. Select Wscript.exe, then select Always use this program to open this file type. This registers Wscript.exe as the default script host for files of this file type.
You can use the Windows Script Host Settings dialog box to set global scripting properties for all scripts that Wscript.exe runs on the local computer 
You can set properties for individual scripts. See Related Topics for information about how to do this.
You can also use Windows Script Host to create .wsf script files, with which you can call multiple scripting engines and perform multiple jobs, all from one file.




Sample programs: 

Copy paste the below code in a note pad and save the files as .vbs in any directory of your personal computer and run the file as above.

Program 1:

'****HelloWorld******

MsgBox "Hello World !!!"

Program 2:

'**** Addition of two numbers***

Dim a,b

a = 1
b = 2

Msgbox "Addition of two number is "&a+b




Some more programs and full description of each program follows in next post




No comments:

Post a Comment