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

更多推荐

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