通过 vbscript 传递 msiexec 开关

Passing msiexec switches through vbscript

我正在尝试通过 vbscript 静默安装 MSI 包,但是当我尝试通过所有开关时,我得到的是空白命令提示符并且 Windows 安装程序工具提示打开。

下面是我尝试过的几种方法,但我每次都得到同样的结果。

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 命令。我怎样才能得到 运行 整个字符串一起安装软件包的完整命令?

您发送给 shell 的命令中似乎缺少一些空格。我将仅以第一个命令为例。这是你写的:

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

下面是该语句构建的命令:

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

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

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

以上将命令格式化为:

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

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