【问题标题】:Passing msiexec switches through vbscript通过 vbscript 传递 msiexec 开关
【发布时间】:2015-10-07 19:42:58
【问题描述】:

我正在尝试通过 vbscript 静默安装 MSI 包,但是当我尝试通过开关时,我得到的只是空白命令提示符和 Windows Installer 工具提示。

我在下面尝试了几种方法,但每次都得到相同的结果。

Dim objShell
Set objShell = Wscript.CreateObject ("Wscript.Shell")
objShell.Run "cmd /c msiexec" & "/i" & Chr(34) & "AppleApplicationSupport64.msi" & Chr(34) & "/quiet" & "/norestart"
objShell.Run "cmd /c msiexec" & "/i" & Chr(34) & "AppleMobileDeviceSupport6464.msi" & Chr(34) & "/quiet" & "/norestart"
objShell.Run "cmd /c msiexec" & "/i" & Chr(34) & "iTunes6464.msi" & Chr(34) & "/quiet" & "/norestart"
objShell.Run "cmd /c msiexec" & "/i" & Chr(34) & "Bonjour64.msi" & Chr(34) & "/quiet" & "/norestart"
objShell.Run "cmd /c msiexec" & "/i" & Chr(34) & "AppleSoftwareUpdate.msi" & Chr(34) & "/quiet" & "/norestart"
Set objShell = Nothing 

我尝试的第二种方法

Dim objShell
Set objShell = WScript.CreateObject( "WScript.Shell" )
objShell.Run("""%userprofile%\Desktop\Deployment\AppleApplicationSupport64.msi""") + "/quiet" + "/norestart"
objShell.Run("""%userprofile%\Desktop\Deployment\AppleMobileDeviceSupport6464.msi""") + "/quiet" + "/norestart"
objShell.Run("""%userprofile%\Desktop\Deployment\iTunes6464.msi""") + "/quiet" + "/norestart"
objShell.Run("""%userprofile%\Desktop\Deployment\Bonjour64.msi""") + "/quiet" + "/norestart"
objShell.Run("""%userprofile%\Desktop\Deployment\AppleSoftwareUpdate.msi""") + "/quiet" + "/norestart"
Set objShell = Nothing

它似乎没有超越 msiexec 命令。如何让它将整个字符串与完整的命令一起运行以安装软件包?

【问题讨论】:

  • 我认为您需要在 msi 开关之间留一个空格 ( )

标签: vbscript windows-installer silent-installer


【解决方案1】:

看起来您在发送到 shell 的命令中缺少一些空格。我将仅检查第一个命令作为示例。这是你写的:

objShell.Run "cmd /c msiexec" & "/i" & Chr(34) & "AppleApplicationSupport64.msi" & Chr(34) & "/quiet" & "/norestart"

这是该语句构建的命令:

msiexec/i"AppleApplicationSupport64.msi"/quiet/norestart

你得到了Windows Installer 窗口,因为它不理解没有空格的命令。相反,在字符串中添加一些空格,如下所示:

   objShell.Run "cmd /c msiexec " & "/i " & Chr(34) & "AppleApplicationSupport64.msi" & Chr(34) & " /quiet" & " /norestart"

上面将命令格式化为:

msiexec /i "AppleApplicationSupport64.msi" /quiet /norestart

这应该可以解决您的问题。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2023-03-06
    • 1970-01-01
    • 1970-01-01
    • 2021-02-08
    • 1970-01-01
    • 2019-10-30
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多