• linkedu视频
  • 平面设计
  • 电脑入门
  • 操作系统
  • 办公应用
  • 电脑硬件
  • 动画设计
  • 3D设计
  • 网页设计
  • CAD设计
  • 影音处理
  • 数据库
  • 程序设计
  • 认证考试
  • 信息管理
  • 信息安全
菜单
linkedu.com
  • 网页制作
  • 数据库
  • 程序设计
  • 操作系统
  • CMS教程
  • 游戏攻略
  • 脚本语言
  • 平面设计
  • 软件教程
  • 网络安全
  • 电脑知识
  • 服务器
  • 视频教程
  • vbs
  • DOS/BAT
  • hta/htc
  • python
  • perl
  • VBA
  • ColdFusion
  • ruby
  • PowerShell
  • Lua
  • Golang
  • linux shell
您的位置:首页 > 脚本语言 >vbs > Wscript 和 Cscript 运行脚本的区别详解

Wscript 和 Cscript 运行脚本的区别详解

作者: 字体:[增加 减小] 来源:互联网

通过本文主要向大家介绍了wscript.shell,wscript,wscript.exe,wscript.echo,wscript.exe是什么等相关知识,希望对您有所帮助,也希望大家支持linkedu.com www.linkedu.com

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.)

</div>

您可能想查找下面的文章:

  • VBS中CreateObject和WScript.CreateObject的区别介绍
  • WScript.Shell对象SpecialFolders属性未公开文档分享
  • VBS变量名Wsh等于WScript对象?
  • vbs下用Shell.Application获取图片分辨率
  • 利用WScript.Shell对象隐藏cmd命令行运行框的实现代码
  • vbScript中WScript.Shell对象的run和exec使用心得分享
  • vbs 中调用shell.application 简单函数
  • 修复Windows上面的WScript的脚本(.vbs)不能执行了
  • 利用wscript执行文件[包括可执行exe文件]vbs脚本
  • Wscript.Shell 对象详细介绍!!特好的东西第1/2页

相关文章

  • 使用 Iisftp.vbs 创建FTP站点的方法
  • VBS教程:VBScript 语句-Rem 语句
  • 收藏的比较精典VBS代码
  • VBS文本文件操作实现代码
  • VBS教程:属性-Name 属性
  • 用VBS脚本实现更换Windows Xp序列号的代码
  • VBS中转换二进制数据为字符串常用办法
  • 如何使用脚本锁定任务栏?
  • IE浏览器增加“复制图像地址”的右键菜单的vbs代码
  • VBS加密解密源码(UserAccounts.CommonDialog) 脚本之家修正版

文章分类

  • vbs
  • DOS/BAT
  • hta/htc
  • python
  • perl
  • VBA
  • ColdFusion
  • ruby
  • PowerShell
  • Lua
  • Golang
  • linux shell

最近更新的内容

    • 两个批量挂马vbs脚本代码
    • 用vbscript合并多个文本文件的代码
    • vbs 搜索代理地址实现代码[小偷程序]
    • 远程开启/关闭目标telnet服务的windows脚本RTCS.vbs
    • VBS 16进制验证特定字符
    • VBS教程:函数-CDbl 函数
    • 用VBSCRIPT控制ONSUBMIT事件
    • VBS教程:运算符-运算符(+)
    • VBS教程:属性-Line 属性
    • 用vbs删除前一天创建的备份文件

关于我们 - 联系我们 - 免责声明 - 网站地图

©2020-2025 All Rights Reserved. linkedu.com 版权所有