下面是代码
$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我想在一个隐藏的窗口中运行这个进程,等待它返回并得到错误、输出和退出代码。
发布于 2010-12-28 13:05:51
根据documentation for Start-Process,重定向参数(RedirectStandardOutput和RedirectStandardError)和WindowStyle参数的组合是无效的,因为它们存在于单独的parameter sets中。
这意味着它们不能一起使用。这就是为什么你会收到这个特殊的错误。
https://stackoverflow.com/questions/4541392
复制相似问题