启动过程给出错误

发布于 2024-10-09 08:23:03 字数 912 浏览 0 评论 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  

,这里有错误:

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

我想在隐藏窗口中运行该进程,等待它返回并获取错误、输出和退出代码。

Here's the code

$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  

And Here's there error:

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

I want to run the process in a hidden window, wait for it to return and get the error, output and exit code.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

怀念你的温柔 2024-10-16 08:23:03

根据 Start-Process 文档,重定向参数的组合(RedirectStandardOutput 和 RedirectStandardError)和 WindowStyle 参数无效,因为它们存在于单独的 参数集

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

According to the documentation for Start-Process, the combination of the redirection parameters (RedirectStandardOutput and RedirectStandardError) and the WindowStyle parameter is invalid since they exist in separate parameter sets.

This means that they cannot be used together. This is why you're receiving that particular error.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文