VBScript将无法从MSI文件正确执行

前端之家收集整理的这篇文章主要介绍了VBScript将无法从MSI文件正确执行前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
我有一个我写的VBScript需要从MSI文件执行.当我在 Windows中独立运行脚本时,脚本会正确执行,但是,当我从安装程序运行它时,我会收到以下错误,如日志文件中所示:
  1. Microsoft VBScript runtime error: object required: 'WScript',Line 3,Column 2

脚本如下:

  1. sub shell(cmd)
  2. Set objShell = WScript.CreateObject("WScript.Shell")
  3.  
  4. objShell.Run("""" & cmd & """")
  5. Set objShell = Nothing
  6. end sub
  7.  
  8. set objFSO = CreateObject("Scripting.FileSystemObject")
  9.  
  10. strcmd32 = "C:\Path\PathToExecutable.exe"
  11. strcmd64 = "C:\Path\PathToExecutable64.exe"
  12.  
  13. if (objFSO.FileExists(strcmd32)) then
  14. shell(strcmd32)
  15. else
  16. shell(strcmd64)
  17. end if
  18.  
  19. set objFSO = Nothing

如前所述,如果我在安装程序的上下文之外运行它,则此脚本运行正常.安装项目类型是VS2010安装和部署包(这是客户希望使用的,我不能使用任何其他东西).有任何想法吗?

在“shell”子句中,我在调用“CreateObject()”之前从第一行中删除了WScript.修改后的行现在看起来像这样:
  1. 'Note the absent reference to WScript on the call to CreateObject()
  2. Set objShell = CreateObject("WScript.Shell")

猜你在找的Windows相关文章