中文字幕av专区_日韩电影在线播放_精品国产精品久久一区免费式_av在线免费观看网站

溫馨提示×

溫馨提示×

您好,登錄后才能下訂單哦!

密碼登錄×
登錄注冊×
其他方式登錄
點擊 登錄注冊 即表示同意《億速云用戶服務條款》

Wscript和Cscript運行腳本有哪些區別

發布時間:2021-09-30 15:15:49 來源:億速云 閱讀:143 作者:iii 欄目:開發技術

本篇內容介紹了“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運行腳本有哪些區別”的內容就介紹到這里了,感謝大家的閱讀。如果想了解更多行業相關的知識可以關注億速云網站,小編將為大家輸出更多高質量的實用文章!

向AI問一下細節

免責聲明:本站發布的內容(圖片、視頻和文字)以原創、轉載和分享為主,文章觀點不代表本網站立場,如果涉及侵權請聯系站長郵箱:is@yisu.com進行舉報,并提供相關證據,一經查實,將立刻刪除涉嫌侵權內容。

AI

高尔夫| 钟山县| 梓潼县| 和静县| 石景山区| 金溪县| 永春县| 瓦房店市| 宜兰县| 遂溪县| 松原市| 银川市| 垦利县| 环江| 嵊州市| 宾阳县| 互助| 永川市| 青铜峡市| 宁城县| 普兰店市| 建瓯市| 洪泽县| 沅江市| 沂南县| 政和县| 泗洪县| 逊克县| 霍林郭勒市| 临洮县| 旬邑县| 武冈市| 五大连池市| 关岭| 涟源市| 克什克腾旗| 榆社县| 靖州| 厦门市| 张家口市| 宜州市|