Windows Script Host
Windows Based Script Host
The wscript.exe is automatically invoked (by default) whenever you double-click on a script file to execute it. In other words, your scripts execute inside the Windows Based Script Host.
Normally, you don’t need to explicitly execute wscript.exe. It is executed manually only for modifying preferences (settings) which are applicable while executing a script. It can be found at “C:\Windows\System32” or you can also execute it from the command line. The following window appears when you execute this program :
This window lets you modify settings for scripts and make them applicable system-wide i.e. these settings apply to every script you run on the computer. The first setting lets you choose whether you want to stop the scripts after they have been active for the specified no. of seconds. The second setting lets you choose whether the logo is to be displayed when the script is executed at the Command Prompt (CMD).
You can also apply different settings to individual script files by right-clicking them and going to the Script tab in the Properties Window. When you modify a script’s settings manually, a file with the same name as the script and with the extension .wsh is created. A .wsh file is a text file and has a format similar to that of .ini files. It contains a [ScriptFile] section, which identifies the script file with which the .wsh file is associated, and an [Options] section, which corresponds to the settings selected by you on the Script tab. A .wsh file, when opened using Notepad, looks like this :
Console Based Script Host
The Console Based Script Host (cscript.exe) is located at “C:\Windows\System32”. You can execute it using the command prompt. It performs the same task as the Windows Based Script Host (i.e. modifying preferences) but using command line switches. You can view the various command-line switches for cscript.exe in the image below :
Note : You can execute a script by either double-clicking it or by using the command line (viz. D:\cscript calc.vbs or D:\wscript calc.vbs). Also, there is no difference in the way the script is executed by cscript or wscript. In other words, the output of the script would be the same irrespective of what program you use to execute it. The difference between wscript and cscript lies in their concept. wscript has been designed as a GUI application while cscript is CLI based.