C# powershell启动进程时使用-重定向标准输出挂起powershell控制台

C# powershell启动进程时使用-重定向标准输出挂起powershell控制台,c#,powershell,console,C#,Powershell,Console,我有一个由c#编写的test.exe,代码只是调用Console.ReadLine(); 我想跑: $p = Start-Process test.exe -RedirectStandardOutput .\out.txt -PassThru 在不带重定向的情况下运行时,标准输出: $p = Start-Process test.exe -PassThru 一切看起来都很好 但如果: $p = Start-Process test.exe -RedirectStandardOutput .\

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

$p = Start-Process test.exe -RedirectStandardOutput .\out.txt -PassThru
在不带重定向的情况下运行时,标准输出:

$p = Start-Process test.exe -PassThru
一切看起来都很好

但如果:

$p = Start-Process test.exe -RedirectStandardOutput .\out.txt  -PassThru
powershell控制台将挂起,在关闭test.exe命令提示符之前,您无法输入任何内容


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

可能重复我无法复制您的问题。您正在使用哪个版本的powershell?控制台应该“挂起”的唯一原因是您正在使用
-Wait
参数。另外,您使用的是实际控制台还是ISE/其他开发工具?@TheIncorrigible1,在运行$p=Start Process test.exe-RedirectStandardOutput.\out.txt-PassThru之后,您是否能够输入任何内容,例如$p来打印流程信息?我使用的是纯powershell控制台,而不是ISE或其他东西。名称值-----PSVersion 5.1.18362.145 PSEdition桌面