在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 "//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.