【发布时间】:2014-07-31 22:13:55
【问题描述】:
有人要求我使用 Powershell 自动执行大型 MSI 安装程序。这个安装程序有大量的安装选项,我正在按照如下所示的语法一一运行这些选项。
我有这个设置来运行所有安装选项,然后检查日志中是否有任何故障,并向我发送电子邮件通知。我无法解决的问题是,如果安装选项失败,在 poweshell 中运行的安装程序会向 UI 抛出一个错误框并暂停安装。这是一个问题,因为我需要运行所有安装,然后评估失败的原因并及时修复。这是正常行为还是我可以修改下面的代码以不在 UI 中显示错误消息?
#Common items
$SourceDirectory = "D:\Temp"
$LogDirectory = "D:\Temp\Script"
$FileName = Get-ChildItem -Path $SourceDirectory | Sort-Object LastAccessTime - Descending | Select-Object -First 1
$FullFileName = $SourceDirectory + "\" + $FileName
#Install option 1
$LogName = $LogDirectory + "\" +"(MSIName).log"
$Arguments = "/i ""$FullFileName"" /qn /norestart /L*V $LogName ADDLOCAL=(install options)"
Start-Process -FilePath msiexec.exe -ArgumentList $Arguments -Wait
#Install option 2
$LogName = $LogDirectory + "\" +"(MSIName).log"
$Arguments = "/i ""$FullFileName"" /qn /norestart /L*V $LogName ADDLOCAL=(install options)"
Start-Process -FilePath msiexec.exe -ArgumentList $Arguments -Wait
我在这里缺少什么?我以 /qn 的身份运行。
【问题讨论】:
标签: powershell windows-installer