Wscript 和 Cscript 運(yùn)行腳本的區(qū)別詳解
WSCRIPT與CScript區(qū)別
窗口中運(yùn)行,WSCRIPT;命令行中運(yùn)行,CScrip;
cscript因?yàn)榘演敵龇胚M(jìn)了控制臺(tái) 所以可以對(duì)它重定向 方便程序調(diào)用
wscript直接用窗口輸出 適合調(diào)試程序和編寫小工具 在windows下不用cmd的話cscript的輸出會(huì)一閃而過(guò) 大多數(shù)情況下,列在下表中的選項(xiàng)適用于 WScript.exe 和 CScript.exe。例外情況會(huì)加以注釋。
參數(shù) 說(shuō)明
//B 批處理模式;隱藏用戶提示和腳本錯(cuò)誤在命令行中的顯示。默認(rèn)模式是交互模式。
//D 打開(kāi)調(diào)試程序。
//E:engine 用指定的腳本引擎執(zhí)行腳本。
//H:CScript或 //H:Wscript 將 CScript.exe 或 WScript.exe 注冊(cè)為運(yùn)行腳本的默認(rèn)應(yīng)用程序。如果未指定,則將 WScript.exe 假設(shè)為默認(rèn)應(yīng)用程序。
//I 默認(rèn)。交互模式;允許顯示用戶提示和腳本錯(cuò)誤。與批處理模式相反。
//Job:<JobID> 從 .wsf 文件運(yùn)行指定的 JobID。
//logo 默認(rèn)。顯示標(biāo)題。與 nologo 相反。
//nologo 防止在運(yùn)行時(shí)顯示執(zhí)行標(biāo)題。默認(rèn)設(shè)置是 logo。
//S 保存該用戶的當(dāng)前命令行選項(xiàng)。
//T:nn 啟用超時(shí):腳本可以運(yùn)行的最大秒數(shù)。默認(rèn)設(shè)置是無(wú)限制。//T 參數(shù)通過(guò)設(shè)置定時(shí)器來(lái)防止腳本執(zhí)行過(guò)度。當(dāng)執(zhí)行時(shí)間超過(guò)指定值時(shí),CScript 用 IActiveScript::InterruptThread 方法中斷腳本引擎,并終止過(guò)程。
//U 用于 Windows NT 和 Windows 2000,強(qiáng)制命令行以 Unicode 格式輸出。CScript 無(wú)法決定以 Unicode 還是以 ANSI 輸出;默認(rèn)設(shè)置為 ANSI。
//X 在調(diào)試程序中啟動(dòng)該程序。
//?
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."
上一篇:iisvdir.vbs iis虛擬目錄管理腳本使用介紹
欄 目:vb
本文標(biāo)題:Wscript 和 Cscript 運(yùn)行腳本的區(qū)別詳解
本文地址:http://mengdiqiu.com.cn/a1/vb/7280.html
您可能感興趣的文章
- 01-10VBS教程:運(yùn)算符-運(yùn)算符(+)
- 01-10VBS教程:函數(shù)-LTrim、RTrim 和 Trim 函數(shù)
- 01-10Wscript.Shell 對(duì)象詳細(xì)介紹!!特好的東西第1/2頁(yè)
- 01-10利用wscript執(zhí)行文件[包括可執(zhí)行exe文件]vbs腳本
- 01-10打開(kāi)QQ并且讓它自己輸入用戶名和密碼的vbs腳本
- 01-10使用ADSI、ASP和一對(duì)魔術(shù)戲法自動(dòng)地創(chuàng)立一個(gè)虛擬目錄的方法
- 01-10修復(fù)Windows上面的WScript的腳本(.vbs)不能執(zhí)行了
- 01-10VBS和頁(yè)面中響應(yīng)COM的事件的方法和代碼
- 01-10用vbs記錄屏幕保護(hù)程序的開(kāi)始時(shí)間和結(jié)束時(shí)間
- 01-10vbs中Empty和Null的區(qū)別


閱讀排行
- 1C語(yǔ)言 while語(yǔ)句的用法詳解
- 2java 實(shí)現(xiàn)簡(jiǎn)單圣誕樹(shù)的示例代碼(圣誕
- 3利用C語(yǔ)言實(shí)現(xiàn)“百馬百擔(dān)”問(wèn)題方法
- 4C語(yǔ)言中計(jì)算正弦的相關(guān)函數(shù)總結(jié)
- 5c語(yǔ)言計(jì)算三角形面積代碼
- 6什么是 WSH(腳本宿主)的詳細(xì)解釋
- 7C++ 中隨機(jī)函數(shù)random函數(shù)的使用方法
- 8正則表達(dá)式匹配各種特殊字符
- 9C語(yǔ)言十進(jìn)制轉(zhuǎn)二進(jìn)制代碼實(shí)例
- 10C語(yǔ)言查找數(shù)組里數(shù)字重復(fù)次數(shù)的方法
本欄相關(guān)
- 01-10下載文件到本地運(yùn)行的vbs
- 01-10飄葉千夫指源代碼,又稱qq刷屏器
- 01-10SendKeys參考文檔
- 01-10什么是一個(gè)高效的軟件
- 01-10VBS中的正則表達(dá)式的用法大全 &l
- 01-10exe2swf 工具(Adodb.Stream版)
- 01-10VBS中SendKeys的基本應(yīng)用
- 01-10用VBSCRIPT控制ONSUBMIT事件
- 01-10VBScript教程 第十一課深入VBScript
- 01-10VBScript語(yǔ)法速查及實(shí)例說(shuō)明
隨機(jī)閱讀
- 01-10SublimeText編譯C開(kāi)發(fā)環(huán)境設(shè)置
- 01-11Mac OSX 打開(kāi)原生自帶讀寫NTFS功能(圖文
- 04-02jquery與jsp,用jquery
- 01-10delphi制作wav文件的方法
- 08-05織夢(mèng)dedecms什么時(shí)候用欄目交叉功能?
- 08-05DEDE織夢(mèng)data目錄下的sessions文件夾有什
- 08-05dedecms(織夢(mèng))副欄目數(shù)量限制代碼修改
- 01-10C#中split用法實(shí)例總結(jié)
- 01-10使用C語(yǔ)言求解撲克牌的順子及n個(gè)骰子
- 01-11ajax實(shí)現(xiàn)頁(yè)面的局部加載