在cmd里敲了wscript.exe Deploy.vbs,但是返回錯誤是 There is no script engine for file extension '.vbs'。這個時候我想到了google。果然搜到了不少有用的信息,其中第一條里我就找到了解決辦法。 原因是我的vbs關聯已經丟失了,必須顯示指定。
大家知道,腳本語言(包括JavaScript和VBscript語言等)經常會被植入網頁之中(其中包括 HTML 頁面客戶機端和 ASP 頁面服務器端) 。對于植入 HTML 頁面的腳本,其所需的解析引擎會由 IE 這樣的網頁瀏覽器載入;對于植入 ASP 頁面的腳本,其所需的解析引擎會由 IIS( Internet Information Services)提供。而對于出現在 HTML 和 ASP 頁面之外的腳本(它們常以獨立的文件形式存在),就需要經由 WSH 來 處理了。需要說明的是:WSH 要想正常工作,還要安裝IE 3.0 或更高版本的 IE,因為 WSH 在工作時會調用 IE 中的 VBScript 和 JavaScript 解析引擎。 [未結束][iduba_page]在這些被植于網頁的腳本語言中,絕大多數是與網絡安全無關的。但也有少數別有用心的好事 者,把一些嚴重危及網絡安全的代碼(我們常常稱之為“惡意代碼”,他們通常都要通過修改注冊表達到“惡意”的目的!),混放在正常的 腳本之中,常常讓我們防不勝防。但是,如果我們了解一點關于腳本語言的知識,這些“伎倆”都是非常容易識破的。還是讓我們從幾個簡單 的實例開始吧……
Q: How do I open script files? Trying the above solution makes Windows XP throw an error?
A: This is similar to the *.js association problem. Some machines seem to, for some reason, lose their *.vbs association. It's not that the files open with dreamweaver or whatever -- it's that the machine just doesn't know how to run them. If you have a scheduled task, "Could not run" will appear in the status column.
So, you're a smart person and read through the FAQ. You find the *.js extension problem, and you try that fix: you run it as "wscript c:\path\to\script.vbs". But that, in turn, produces a pop-up error, this time a "Windows Scripting Host" error: "There is no script engine for file extension '.vbs'." So, for some reason, wscript doesn't even know what to do with *.vbs files.
The solution to this problem is to run the script as:
wscript //e:vbscript c:\path\to\script.vbs
The "http://e:vbscript" tells wscript to use the vbscript engine to parse the script. It will then run correctly.
A few alternative solutions, perhaps easier are:
Rename it .vbe (VBScript Encoded Script File). Not sure if this is a bad idea, but it seemed to work for some scripts. Make a new association for VBS. Open up my computer, select Tools menu-> Folder Options, and go to the File Types tab. There probably isn't a VBS association listed if you have this problem. Select New, type in VBS, and hit Advanced>>. Then, from the pull-down menu, select "VBScript Script File". Making this selection automatically takes care of the association, along with the //e:vbscript problem. This is probably the "correct" solution... This problems usually occurs only on Windows XP machines, but the cause is not known. A Microsoft KB article on this issue can be found here. Thanks goes to Bob_2k for writing this FAQ entry.