These examples are simple and straightforward. They use VBScript and JScript to display a message with an OK button. When you double-click on the script, the script host would be called, and the script will be executed.
Here is the example VBScript:
WScript.Echo “Welcome to Windows”
WScript.Quit
Here is the same program in JScript.
WSH.Echo (“Welcome to Windows”);
WSH.Quit();
Note: The VBScript program is saved in .vbs file and the JScript file is saved in a .js file.
You can also mix JScript and VBScript (and any other) in a single .wsf file. However, the format of the code in a .wsf file slightly changes, as you will see in the code below that this code resembles XML:
<userjob1>
<script language="JScript">
WSH.echo("How are you message from JScript");
</script>
<script language="VBScript">
MsgBox "How are you message from VBScript"
</script>
</userjob1>
You see how easy it is to write a script. To run your script, you can either go to the command prompt and enter “cscript yourscriptname.extension”, or open the RUN window and enter wscript yourscriptname.extension. For example: wscript folderdelete.vbs
If you are familiar with basic C or VB programming, then writing these scripts would be no problem for you. To learn more about WSH, JScript or VBScripts, you may check out Microsoft.com, Technet.com, W3Schools.com.
I hope you found this windows scripting host tutorial easy. If you have any question about WSH or want to share anything about it, you may write your message in the comments section below.