Powershell Start-Process 后被调用程序的返回值

368 阅读1分钟

本文已参与「新人创作礼」活动,一起开启掘金创作之路。

Powershell Start-Process 程序返回值

使用 Powershell 调用 winform 程序,但是发现无法获取 winform 程序的返回值。 在 Start-Process 中加入参数 -PassThru 就可以获取到 winform 程序的返回值了。

-PassThru Returns a process object for each process that the cmdlet started. By default, this cmdlet does not generate any output.

$proc = Start-Process test.exe -ArgumentList "testarg1 testarg2" -Wait -PassThru
$proc.ExitCode