【发布时间】:2020-01-17 10:14:59
【问题描述】:
我是 powershell 的新手。我正在处理一个没有间歇性启动服务的脚本。
$sensuresult = Start-Process -Wait -FilePath $filepath -ArgumentList '/tasks="assocfiles,modpath" /quiet' -PassThru
基本上,我们在这里尝试安装一个 .msi 包。上述行间歇性地失败。
Write-Host $sensuresult
Write-Host : The following exception occurred while retrieving the string: "Process has exited, so
the requested information is not available."
At line:8 char:1
+ Write-Host $sensuresult
+ ~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : NotSpecified: (:) [Write-Host], ExtendedTypeSystemException
+ FullyQualifiedErrorId :
ToStringPSObjectBasicException,Microsoft.PowerShell.Commands.WriteHostCommand
有了上面的错误信息,我真的不知道是 Start-Process 失败还是 Write-host。
我能否了解一下 Start-Process 为什么不间歇性地安装软件包以及执行此操作的最佳替代方法是什么?
【问题讨论】: