powershell - 排队 MSI 安装 - 通过 Powershell

标签 powershell windows-installer silent

我正在尝试在我们的 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/

相关文章:

testing - 模拟 Windows 安装程序

Wix组件,文件位于不同目录中

csv - 仅查询非空值并重命名字段?

powershell 如何遍历文件并压缩它们

windows - 如何在powershell中下载整个dropbox目录?

Wix重大升级,无论新文件版本如何替换文件

c++ - 什么是 C++ 中的 .pyw 文件?

ios - iOS 应用程序可以将设备切换到静音模式吗?

指定路径的Java JDK静默安装

powershell - 在 windows 10 中从 powershell 启动通用 windows 应用程序 (UWA)