为什么WScript.CreateObject(“WScript.Shell”)应该崩溃?

时间:2022-03-15 21:28:45

Do you think of any reason that this line should crash: Set oShell = WScript.CreateObject ("WScript.Shell")

你认为这一行应该崩溃的原因是什么:设置oShell = WScript.CreateObject(“WScript.Shell”)

... only if I launch the script from InstallShieldExpress as a custom-action.

...仅当我从InstallShieldExpress启动脚本作为自定义操作时。

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

I never see the "after create ObjectShell" message ;-(

我从来没有看到“after create ObjectShell”消息;-(

and if I simply launch the script by double-clicking on the script file in a windows explorer, of course everything is ok.

如果我只是通过双击Windows资源管理器中的脚本文件来启动脚本,当然一切正常。

1 个解决方案

#1


2  

It may be that the global WScript object isn't available in the InstallShield environment. You can check this using a script like this:

可能是InstallShield环境中的全局WScript对象不可用。你可以使用这样的脚本来检查:

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

If WScript is undefined, try using CreateObject("WScript.Shell") instead. See also What is the difference between CreateObject and Wscript.CreateObject?

如果未定义WScript,请尝试使用CreateObject(“WScript.Shell”)。另请参见CreateObject和Wscript.CreateObject有什么区别?

#1


2  

It may be that the global WScript object isn't available in the InstallShield environment. You can check this using a script like this:

可能是InstallShield环境中的全局WScript对象不可用。你可以使用这样的脚本来检查:

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

If WScript is undefined, try using CreateObject("WScript.Shell") instead. See also What is the difference between CreateObject and Wscript.CreateObject?

如果未定义WScript,请尝试使用CreateObject(“WScript.Shell”)。另请参见CreateObject和Wscript.CreateObject有什么区别?