<

Difference between cscript and wscript

Published on
6,522 Points
3,522 Views
Last Modified:
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:
An ActiveX control that provides the core object model for the scripting host. Scripting Engines

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 console applications and WScript is for Windows applications. The Kernel 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:1.jpg
When we execute the above VBScript with CScript.exe, it displays hi (called through WScript.echo) in command prompt.

When using WScript.exe:
2.jpg

When we execute the above VBScript with WScript.exe, it displays hi (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.
WSCript        -> an object in Core Object Model provided in WSH.
Usage of CSCript.exe:
The command line options for CSCript.exe are in this screenshot.
3.jpg[ ] refers to optional data, i.e., not mandatory. 

Usage of WSCript.exe:
The command line options for WSCript.exe in this screenshot.
41.jpg
Again, [ ] refers to optional data, i.e., not mandatory. 
 
0
Comment
0 Comments

Featured Post

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Join & Write a Comment

The goal of this video is to provide viewers with basic examples to understand and use conditional statements in the C programming language.
This theoretical tutorial explains exceptions, reasons for exceptions, different categories of exception and exception hierarchy.

Keep in touch with Experts Exchange

Tech news and trends delivered to your inbox every month