昨天下载并且安装了Updater Application Block后,需要执行一个Deploy.vbs的文件,鄙人才疏学浅,这个小问题竟然也花费了我不少心机。7 w. e( G4 B+ l
现在把结论共享一下。 ' u# D3 u+ i( V5 z) s% {. D. ^& h 5 B4 T" g3 j% z+ T% j# h" D1 N9 A首先,我的vbs文件关联已经被“豪杰”夺取了。我双击Deploy.vbs就会打开豪杰,比较郁闷。但是我用了打开方式,试了浏览器、cmd,都无济于事。 6 U. E' _7 F. P/ ?6 l! d! A* q' n2 j4 ] {/ [7 y" _* g' a
今天,我想到这个问题后,就有想法去Microsoft的News Group上去问一问。然后又去了CSDN的全文检索。果然很争气,我的关键字只是vbs,执行,就找到了一大堆我想要的东东。了解到用wscript.exe来执行这个文件。( H" E$ [, }. ?8 {- c5 \4 g
- E/ [/ J+ L* a( Q* H7 [在cmd里敲了wscript.exe Deploy.vbs,但是返回错误是 There is no script engine for fileextension '.vbs'。这个时候我想到了google。果然搜到了不少有用的信息,其中第一条里我就找到了解决办法。原因是我的vbs关联已经丢失了,必须显示指定。, I( S3 b% x8 M, q
! M8 O$ C0 R' n8 ?. |cmd中敲入 wscript.exe //e:vbscript Deploy.vbs。果然成功!!! 8 v0 v2 w6 }$ D1 v7 `- M $ L; F! h; a. ^& D/ M! ?. _ : u. K5 O1 C! D: r" m9 _ y. b
+ m# V& ~0 [* B5 F0 U0 e2 w% [
总结:用wscript.exe 执行类似vbs这类的脚本文件。如果文件关联丢失。可以用//e:vbscript.7 S2 z- @, R" ]' j1 @5 P/ X
1 C o2 Y( d7 ?+ ^
" x6 u1 T# e2 q ]5 [& Q( g . n+ o/ g: K/ L! E. l附上我找到的很有帮助的文章。6 D/ a2 i! ^1 L" p: {# c1 c
# u( }9 T) j7 y/ P5 Q. l 7 M$ L8 j3 A8 ^* p( b3 D: D0 `4 s% a& K' j
一、什么是WSH? ; g$ H8 d0 D3 ?+ g7 j
2 x0 b2 T- E9 ~1 s
WSH是Windows Scripting Host(Windows脚本主机)的缩略形式。WSH这个概念最早出现于Windows98操作系统,是一个基于32 位 Windows 平台、并独立于语言的脚本运行环境。比如:你自己编写了一个脚本文件,如后缀为 .vbs 或.js 的文件,然后在 Windows 下双击 并执行它,这时,系统就会自动调用一个适当的程序来对它进行解释并执行,而这个程序,就是Windows Scripting Host,程序执行文件名为 Wscript.exe (若是在DOS命令提示符下,则为Cscript.exe)。 ) D$ F' e1 @1 E3 {' S$ }4 E
* `, q- v2 n7 b1 g& w
$ W% F$ ~% p) l2 J2 D 1 o ]6 u: `# H A$ R5 e 想知道自己的机器上有没有WSH吗?查看一下你的机器里有没有“Wscipt.exe”或者“Cscript.exe”这两个文件就可以了。如果找到,恭 喜你!你已经安装了WSH。否则,自己手动安装吧: 5 B+ w& B9 R4 u1 }" d- Y
% t% ~7 a7 c! s+ r
在Windows98环境下,WSH是作为操作系统的一个组件自动安装的,如果不慎丢失了这个组件,可以从依次打开“控制面板-->添加/删除程序--〉Windows安装程序--〉附件”,然后将“Windows ScriptingHost”前的划上“√”,再确定即可完成WSH组件的安装。 5 p! e* [8 a; F/ s- W: g5 d3 F8 y+ C8 n& q6 N; A0 S% b
5 b: y% X0 Q/ Y7 {2 @1 S7 A+ V 3 z( \" g# O8 x% g$ h: B9 _6 R 二、脚本语言与WSH的关系 " C/ K6 Y* K% J: F( ~" R) ]
0 J. W M$ V% n h% M: N& o
大家知道,脚本语言(包括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]在这些被植于网页的脚本语言中,绝大多数是与网络安全无关的。但也有少数别有用心的好事者,把一些严重危及网络安全的代码(我们常常称之为“恶意代码”,他们通常都要通过修改注册表达到“恶意”的目的!),混放在正常的脚本之中,常常让我们防不胜防。但是,如果我们了解一点关于脚本语言的知识,这些“伎俩”都是非常容易识破的。还是让我们从几个简单 的实例开始吧…… # V; U K$ I/ M j6 k1 h' ]! h( s. F3 I4 O+ |) `" w( |1 E
3 o1 u+ I. M/ e/ C . ?& _$ F6 T/ y$ ]( {" x! |0 `# | 三、WSH应用举例 7 {! y6 y! I1 p+ I& P
4 o5 [# n1 w; ]0 b, n: N1 b ( k- v) J" A8 k u* X; R
- E$ u9 R* _: D$ m8 D & {' f0 u Q3 V: L3 J9 K5 N" I2 m. l0 H" _( H6 ]9 S
$ [% e! A1 O1 N# p$ O$ w; I8 n
: ^- ?% w- L$ z4 k
Q: How do I open script files? Trying the above solution makes Windows XP throw an error? $ |$ L) @3 i+ r! x & c4 G0 W! s/ \6 a T7 K2 WA:This is similar to the *.js association problem. Some machines seem to,for some reason, lose their *.vbs association. It's not that the filesopen with dreamweaver or whatever -- it's that the machine just doesn'tknow how to run them. If you have a scheduled task, "Could not run"will appear in the status column. " [ v' l1 K; S2 o! ?* Z* f% P , Y9 D0 {2 F% f# HSo, you're a smart person andread through the FAQ. You find the *.js extension problem, and you trythat fix: you run it as "wscript c:\path\to cript.vbs". But that, inturn, produces a pop-up error, this time a "Windows Scripting Host"error: "There is no script engine for file extension '.vbs'." So, forsome reason, wscript doesn't even know what to do with *.vbs files., X# P# N; v2 m9 S2 E9 @( j; f
& |+ i5 X2 e( v- E7 K% FThe solution to this problem is to run the script as: ( a6 z2 J$ @0 j7 C+ { q0 p; u- k, i2 B
wscript //e:vbscript c:\path\to cript.vbs5 {3 Q. N5 `) a" ]. L0 a5 T3 b
& i( Z9 U" \/ P4 ^The "//e:vbscript" tells wscript to use the vbscript engine to parse the script. It will then run correctly.* m' d+ T# S( e) F8 `/ [ }) P, N) y! c; |
0 V: e$ N' N- ~/ u R. eA few alternative solutions, perhaps easier are: ( f/ Y# x3 ?! A0 Z3 [% h3 q; TRenameit .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 tothe File Types tab. There probably isn't a VBS association listed ifyou have this problem. Select New, type in VBS, and hitAdvanced>>. Then, from the pull-down menu, select "VBScriptScript File". Making this selection automatically takes care of theassociation, along with the //e:vbscript problem. This is probably the"correct" solution... : V; L F- t9 L0 M8 E1 g. e9 S
This problems usually occurs only on WindowsXP machines, but the cause is not known. A Microsoft KB article on thisissue can be found here. Thanks goes to Bob_2k for writing this FAQentry.