2011-03-21 50 views
0

你认为什么原因令这条线应该崩溃: 设置oShell = WScript.CreateObject(“WScript.Shell”)为什么WScript.CreateObject(“WScript.Shell”)应该崩溃?

...只有当我从推出的InstallShieldExpress脚本作为自定义操作。

MsgBox "before create ObjectShell" 
Set oShell = WScript.CreateObject ("WScript.Shell") 
MsgBox "after create ObjectShell" 

我从来没有看到“创建后ObjectShell”消息;-(

,如果我只需双击脚本文件启动脚本在Windows资源管理器,当然一切正常。

回答

2

这可能是全球WScript对象不在的InstallShield环境中可用您可以在此使用这样的脚本检查:

MsgBox Not IsEmpty(WScript) ' True if WScript is defined, False if it's undefined 

如果WScript未定义,请尝试使用CreateObject("WScript.Shell")代替。另请参阅What is the difference between CreateObject and Wscript.CreateObject?

+0

正确,InstallShield不支持WScript。 – ConfusedDeer 2017-09-20 20:47:21