首页 > 解决方案 > 带有 -RedirectStandardOutput 的 powershell 启动进程挂起 powershell 控制台

问题描述

我有一个用c#写的test.exe,代码就是调用Console.ReadLine(); 我想跑:

$p = Start-Process test.exe -RedirectStandardOutput .\out.txt -PassThru

在没有 -RedirectStandardOutput 的情况下运行时:

$p = Start-Process test.exe -PassThru

一切看起来都很好。

但如果:

$p = Start-Process test.exe -RedirectStandardOutput .\out.txt  -PassThru

powershell 控制台挂起,您无法输入任何内容,直到您关闭 test.exe 命令提示符。

为什么会发生这种情况,无论如何可以保持 test.exe 运行,我仍然可以使用 powershell 控制台?

标签: c#powershellconsole

解决方案


推荐阅读