【发布时间】:2020-04-11 19:55:21
【问题描述】:
$check = Get-Process -Name 'msiexec'
if($check -eq $null)
{
Write-Host 'ready for installation'
}
else
{
Write-Host 'waiting for completion of current process'
Sleep(10)
if($check -eq $null)
{
Write-Host 'ready for installation'
}
else
{
Write-Host 'stopping the process'
Stop-Process -Name 'msiexec' -Force
}
}
所以在上面第一行的代码中,它给出了错误对象未找到,因为当没有安装正在进行时 msiexec 没有运行,所以如何在 try & catch 中处理它
【问题讨论】:
标签: powershell scripting powershell-3.0 powershell-4.0