通过vbscript传递msiexec开关

时间:2015-10-07 19:42:59

标签: vbscript msiexec silent-installer

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

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

Windows Installer tooltip that comes up when running script

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命令。如何让整个字符串一起运行整个命令来安装软件包?

1 个答案:

答案 0 :(得分: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

这应解决您的问题。

相关问题