![](/img/trans.png)
[英]Specific .exe gives error when launched through PowerShell start-process [powershell]
[英]Start-Process gives error
这是代码
$tool = "E:\Experiments\Popup\latest\xperf.exe"
$toolOutput = "XPerfOutput.log"
$toolError = "XPerfError.log"
$command = "-stop"
$x = Start-Process -FilePath $tool -ArgumentList $command -RedirectStandardOutput $toolOutput -RedirectStandardError $toolError -WindowStyle Hidden -PassThru -Wait
这里有错误:
Start-Process : Parameter set cannot be resolved using the specified named parameters. At E:\Experiments\Popup\asd.ps1:9 char:1
+ Start-Process -FilePath $tool -ArgumentList $command -RedirectStandardOutput $toolOutput RedirectStandardError $toolError -WindowStyle Hidden
-PassThru -Wait
+ ~~~~~~~~~~~~~
+ CategoryInfo : InvalidArgument: (:) [Start-Process], ParameterBindingException
+ FullyQualifiedErrorId : AmbiguousParameterSet,Microsoft.PowerShell.Commands.StartProcessCommand
我想在隐藏窗口中运行该进程,等待它返回并获取错误,输出和退出代码。
根据Start-Process的文档,重定向参数(RedirectStandardOutput和RedirectStandardError)和WindowStyle参数的组合无效,因为它们存在于单独的参数集中 。
这意味着它们不能一起使用。 这就是您收到该特定错误的原因。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.