Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/ssl/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Powershell 启动过程出现错误_Powershell_Powershell 2.0 - Fatal编程技术网

Powershell 启动过程出现错误

Powershell 启动过程出现错误,powershell,powershell-2.0,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 -RedirectStandardE

这是密码

$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
我想在隐藏窗口中运行进程,等待它返回并获取错误、输出和退出代码。

根据,重定向参数(RedirectStandardOutput和RedirectStandardError)和WindowsStyle参数的组合无效,因为它们存在于单独的窗口中


这意味着它们不能一起使用。这就是您收到该特定错误的原因。

$xperfolder的值是多少?您正在将$XPerfFolder合并到“C:\Experiment\…”。除非$XPerfFolder是空的,否则它就没有任何意义。现在这里已经修复了这个问题。代码是好的,当遇到错误时,特定的EXE行为不好。我注意到它倾向于弹出UI而不是写入stderr。@scott saad好的,那么我将如何捕获错误并输出?遗憾的是,修复方法是删除-WindowStyle Hidden。我将对此提交一个bug,以调查为什么会出现这种情况,并在可能的情况下进行修复。这已在PowerShell v.3中修复。但是,在传统的Windows机器上,例如Windows 7(与v.2一起提供),您就不走运了。