This section provides tutorial example on how to run a simple VBScript code file with the Windows Script Host tool.
Windows Script Host (WSH) is a Windows administration tool that provides host environments
for several scripting languages including VBScript.
VBScript codes included in script files will be executed by WSH directly on
the Windows operating system.
If you are running a Windows XP system, you can try these steps to run a simple VBScript
code with Windows Script Host:
1. Create a script file called hello.vbs:
WScript.StdOut.WriteLine "Hello World! - VBScript in WSH"
2. Run hello.vbs with the "cscript" command in a command window:
C:\herong>cscript hello.vbs
Microsoft (R) Windows Script Host Version 5.6
Copyright (C) Microsoft Corporation 1996-2001. All rights reserved.
Hello World! - VBScript in WSH
Congratulations. You have successfully written a VBScript code for the host environment
provided by WSH!
What happened here was:
We created a simple VBScript code file.
The VBScript code calls the "WScript.StdOut.WriteLine" function,
which is a function provided by the WSH host environment
to print a text string to the standard output channel - the command window in this case.