Windows Script Host (WSH)
has been part of Windows since Windows NT4. Windows Script Host provides architecture for building dynamic scripts that consist of a core object model, scripting hosts, and scripting engines.
The key components of Windows Script Host are CSCript, WScript, WSH ActiveX Control and Scripting engines.
WSH ActiveX Control:
that provides the core object model for the scripting host. Scripting Engines
Scripting engines provide the core functions, objects, and methods for a particular scripting language. VBScript and JScript scripting engines are installed by default on Windows.
CSCript and WScript are executables for the scripting host that are used to run the scripts. CSCript and WScript are both interpreters to run VBScript (and other scripting languages like JScript) on the Windows platform.
CSScript is for
applications and WScript is for
checks a flag in the executable to determine which
When starting using CreateProcess, if it is a console application, the kernel will create a console window for it if the parent process doesn't have one, and attach the STDIN and STDOUT and STDERR to the console. If it is a Windows application, no console will be created and STDIN, STDOUT and STDERR will be closed by default.
If you want your script to have a console window, use CSCRIPT.EXE. If you want it to NOT have a console window, use WSCRIPT.EXE.
This also affects some behaviors, such as the WScript.Echo command. In a CSCRIPT.EXE this writes a line to the console window. In WSCRIPT.EXE it shows a messagebox.
When using CScript.exe:
When we execute the above VBScript with CScript.exe, it displays
(called through WScript.echo) in command prompt.
When using WScript.exe:
When we execute the above VBScript with WScript.exe, it displays
(called through WScript.echo) in MessageBox. MsgBox will display a message box in both cases.
The WScript word in WScript.echo is not related to WScript.exe.
WScript.exe -> a command line executable for WSH.
Usage of CSCript.exe:
WSCript -> an object in Core Object Model provided in WSH.
The command line options for CSCript.exe are in this screenshot.
[ ] refers to optional data, i.e., not mandatory.
Usage of WSCript.exe:
The command line options for WSCript.exe in this screenshot.
Again, [ ] refers to optional data, i.e., not mandatory.