足球游戏_中国足彩网¥体育资讯$

wscript和cscript 运行脚本的区别详解
来源:易贤网 阅读:1221 次 日期:2016-06-17 09:34:36
温馨提示:易贤网小编为您整理了“wscript和cscript 运行脚本的区别详解”,方便广大网友查阅!

wscript与cscript区别

窗口中运行,wscript;命令行中运行,cscrip;

cscript因为把输出放进了控制台 所以可以对它重定向 方便程序调用

wscript直接用窗口输出 适合调试程序和编写小工具 在windows下不用cmd的话cscript的输出会一闪而过 大多数情况下,列在下表中的选项适用于 wscript.exe 和 cscript.exe。例外情况会加以注释。

参数说明

//b

批处理模式;隐藏用户提示和脚本错误在命令行中的显示。默认模式是交互模式。

//d

打开调试程序。

//e:engine

用指定的脚本引擎执行脚本。

//h:cscript或 //h:wscript 将 cscript.exe 或 wscript.exe 注册为运行脚本的默认应用程序。如果未指定,则将 wscript.exe 假设为默认应用程序。

//i

 默认。交互模式;允许显示用户提示和脚本错误。与批处理模式相反。

//job:<jobid>

从 .wsf 文件运行指定的 jobid。

//logo

默认。显示标题。与 nologo 相反。

//nologo

防止在运行时显示执行标题。默认设置是 logo。

//s

保存该用户的当前命令行选项。

//t:nn

启用超时:脚本可以运行的最大秒数。默认设置是无限制。//t 参数通过设置定时器来防止脚本执行过度。当执行时间超过指定值时,cscript 用 iactivescript::interruptthread 方法中断脚本引擎,并终止过程。

//u

用于 windows nt 和 windows 2000,强制命令行以 unicode 格式输出。cscript 无法决定以 unicode 还是以 ansi 输出;默认设置为 ansi。

//x

在调试程序中启动该程序。

//?    

微软的解释:

script hosts

the script host initiates and coordinates the running of your script; it reads your script file and interacts with components of the wsh environment and any com objects required by the script. it is also the responsibility of the script host to determine which language engine to use when running the script. for example, if the script has a .vbs extension, the script host will load the vbscript language engine and begin working with that engine to execute the code.

the wsh environment includes two script hosts: the console-based cscript and the gui-based wscript. the two script hosts provide nearly identical capabilities, and in most cases, it does not matter which of the script hosts you use to run your scripts.

the two exceptions lie in how you interact with a script; that is, how you get information into a script (input) and how the script displays information it has retrieved (output). in general, cscript receives input from the command prompt and displays output in a command window. wscript, by contrast, receives input through a graphical dialog box and displays output in a graphical message box.

otherwise, the two script hosts are largely identical: if you have a script that does not require user interaction, you can run that script under either cscript or wscript. for example, the following script maps a network drive. because it neither requires input nor displays output, it runs exactly the same under either script host:

set objnetwork = wscript.createobject(wscript.network)objnetwork.mapnetworkdrive g:, \\atl-fs-01\sales

on the other hand, the following script which displays a series of messages runs much differently under cscript (where the messages are displayed as individual lines within a command window) and wscript (where the messages are displayed as a series of message boxes). if you are interested in seeing the difference for yourself, copy the script into notepad, save it with a .vbs file extension, and then run it under both cscript and wscript. (for more information about running scripts under a script host, see running wsh scripts later in this chapter.)

代码如下:

wscript.echo line 1.

wscript.echo line 2.

wscript.echo line 3.

wscript.echo line 4.

中国足彩网信息请查看脚本栏目
易贤网手机网站地址:wscript和cscript 运行脚本的区别详解
由于各方面情况的不断调整与变化,易贤网提供的所有考试信息和咨询回复仅供参考,敬请考生以权威部门公布的正式信息和咨询为准!
关于我们 | 联系我们 | 人才招聘 | 网站声明 | 网站帮助 | 非正式的简要咨询 | 简要咨询须知 | 加入群交流 | 手机站点 | 投诉建议
工业和信息化部备案号:滇ICP备2023014141号-1 足球游戏_中国足彩网¥体育资讯$ 滇公网安备53010202001879号 人力资源服务许可证:(云)人服证字(2023)第0102001523号
云南网警备案专用图标
联系电话:0871-65317125(9:00—18:00) 获取招聘考试信息及咨询关注公众号:hfpxwx
咨询QQ:526150442(9:00—18:00)版权所有:易贤网
云南网警报警专用图标