cscript和wscript之间的区别

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 using CScript.exe:

1.jpg

使用CScript.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

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

Usage of WSCript.exe:

WSCript.exe的用法:

The command line options for WSCript.exe in this screenshot.

此屏幕快照中WSCript.exe的命令行选项。

41.jpg

翻译自: https://www.experts-exchange.com/articles/17325/Difference-between-cscript-and-wscript.html

  • 1
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值