System administrators use Windows Script Host (WSH) files to manage files, update the registry, and perform advanced networking tasks. Windows Script Host uses very little memory and supports multiple scripting languages such as VBScript and JScript. Run WSH files in graphical user interface mode, or execute them from the Windows command line. If you have no programming skills, you can still enjoy the time-saving benefits provided by Windows Script Host.
Create Test File
Open Notepad and add the following text to a new document:
WSH.Echo( "Testing" );
This is a WSH command that displays the word "Testing".
Click "File", and then "Save As". The "Save As" window will open and display your files and folders. Navigate to a folder where you want to save the file.
Enter a name for the file in the "File Name" text box. Give the file an extension of ".js". For example, if you want to name the file "Test1", enter "Test1.js" (without the quotes) in the text box. Click "Save". Notepad will save the file as a JScript file in the folder that you selected.
Execute Test File
Open Windows Explorer and navigate to the folder that contains the file.
Double-click the file. Windows Script Host will execute the file and display "Testing" in a pop-up window.
Click the Windows "Start" menu. Type "run" and press "Enter". If you use Windows XP, click "Run" to open the "Run" window.
Type "cmd" and press "Enter". The command window will open.
Type Cscript.exe xyz. Replace xyz with the full path name of the file that you created. For instance, if you saved the file as "C:\Myfolder\Test1.js," type the following in the "Command" window:
Windows Script Host will execute the file and display a WSH log followed by the "Testing" message. The results will appear in the "Command" window.
Type the command again. This time, add "//NoLogo" (without the quotes) after the "Cscript" command. Instead of typing "Cscript C:\Myfolder\Test1.js," type the following instead:
Cscript //NoLogo C:\Myfolder\Test1.js
"//NoLogo" is a command line switch. Windows Script Host has several command line switches that you can add to a "Cscript" command. The "//NoLogo" switch suppresses the WSH logo.
Press "Enter" to execute the command. The test message will appear without the WSH logo.