R.D*_*R.D 8 powershell powershell-2.0
这是代码
$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
Run Code Online (Sandbox Code Playgroud)
这里有错误:
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
Run Code Online (Sandbox Code Playgroud)
我想在隐藏窗口中运行该进程,等待它返回并获取错误,输出和退出代码.
Sco*_*aad 11
根据Start-Process的文档,重定向参数(RedirectStandardOutput和RedirectStandardError)和WindowStyle参数的组合无效,因为它们存在于单独的参数集中.
这意味着它们不能一起使用.这就是您收到该特定错误的原因.
归档时间: |
|
查看次数: |
4922 次 |
最近记录: |