我正在尝试在我们的 Win2008 实例上安装 32 位和 64 位版本的 Visual Studio 2005 作为 Powershell 脚本的一部分。当我尝试不间断地调用两个 EXE 文件的安装时,第二个 EXE (x86) 不会执行,因为 x64 尚未完成安装。
所以,我在每次调用后添加了一个 5 秒的 sleep 时间,这似乎现在可以工作了。但是,我对这个解决方案不太满意,因为它看起来更像是一种解决方法,而不是处理手头任务的正确方法。
有没有更好的方法来做到这一点 - 也许将文件排入队列以进行安装 - 所以它们一个接一个地执行?
以下是具体的代码行:
if ($OSArchitecture -eq "64-bit")
{ Write-Output "Found 64-bit OS. Installing both VC++ files for compat"
start-process .\vcredist_x64.exe /Q
start-sleep 5
start-process .\vcredist_x86.exe /Q
start-sleep 5
}
最佳答案
您必须使用 Start-Process -Wait 参数。
-Wait Waits for the specified process to complete before accepting more input. This parameter suppresses the command prompt or retains the window until the process completes.
关于powershell - 排队 MSI 安装 - 通过 Powershell,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/21346499/