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.
自Windows NT4以来, Windows脚本宿主(WSH)就已成为Windows的一部分。 Windows脚本宿主提供了用于构建包含核心对象模型,脚本宿主和脚本引擎的动态脚本的体系结构。
The key components of Windows Script Host are CSCript, WScript, WSH ActiveX Control and Scripting engines.
Windows脚本宿主的关键组件是CSCript,WScript,WSH ActiveX控件和脚本引擎。
WSH ActiveX Control:
WSH ActiveX控件:
An ActiveX control that provides the core object model for the scripting host. Scripting Engines
一个ActiveX控件 ,为脚本宿主提供核心对象模型。 脚本引擎
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.
脚本引擎提供了特定脚本语言的核心功能,对象和方法。 Windows上默认安装了VBScript和JScript脚本引擎。
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.
CSCript和WScript是脚本宿主的可执行文件,用于运行脚本。 CSCript和WScript都是在Windows平台上运行VBScript(和其他脚本语言,如JScript)的解释器。
CSScript is for console applications and WScript is for Windows applications. The Kernel checks a flag in the executable to determine which
CSScript用于控制台应用程序,WScript用于Windows应用程序。 内核检查可执行文件中的标志以确定哪个
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.
当开始使用CreateProcess时,如果它是一个控制台应用程序,则如果父进程没有一个,则内核将为其创建一个控制台窗口,并将STDIN和STDOUT和STDERR附加到控制台。 如果它是Windows应用程序,则不会创建任何控制台,并且默认情况下将关闭STDIN,STDOUT和STDERR。
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.
如果您希望脚本具有控制台窗口,请使用CSCRIPT.EXE。 如果希望它没有控制台窗口,请使用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.
这也会影响某些行为,例如WScript.Echo命令。 在CSCRIPT.EXE中,这会在控制台窗口中写入一行。 在WSCRIPT.EXE中,它显示一个消息框。
When we execute the above VBScript with CScript.exe, it displays hi (called through WScript.echo) in command prompt.
当我们使用CScript.exe执行上述VBScript时,它将在命令提示符下显示
When using WScript.exe:
使用WScript.exe时:
![2.jpg](https://i-blog.csdnimg.cn/blog_migrate/2ef9830aa8e91a792e8f3b4de2166ab2.png)
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.
当我们使用WScript.exe执行上述VBScript时,它在MessageBox中显示
The WScript word in WScript.echo is not related to WScript.exe.
WScript.echo中的WScript单词与WScript.exe不相关。
WSCript -> an object in Core Object Model provided in WSH.
WSCript-> WSH中提供的核心对象模型中的对象。
Usage of CSCript.exe:
CSCript.exe的用法:
The command line options for CSCript.exe are in this screenshot.
此屏幕快照中包含CSCript.exe的命令行选项。
![3.jpg](https://i-blog.csdnimg.cn/blog_migrate/171ba006bbad5a4a4cdaabfd2ac23e82.png)
Usage of WSCript.exe:
WSCript.exe的用法:
The command line options for WSCript.exe in this screenshot.
此屏幕快照中WSCript.exe的命令行选项。
![41.jpg](https://i-blog.csdnimg.cn/blog_migrate/aaaf66fbc4d903e42b38c4e4a49b38a5.png)
翻译自: https://www.experts-exchange.com/articles/17325/Difference-between-cscript-and-wscript.html