2

I have a test.exe written by c#, the code is simply call Console.ReadLine(); and I want to run:

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

when run without -RedirectStandardOutput:

$p = Start-Process test.exe -PassThru

everything looks good.

but if:

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

the powershell console hang, you cannot input anything, until you close the test.exe command prompt.

why this happen, anyway can keep test.exe running and I still can use the powershell console?

xinglong
  • 115
  • 1
  • 5
  • Possible duplicate of [Capturing standard out and error with Start-Process](https://stackoverflow.com/questions/8761888/capturing-standard-out-and-error-with-start-process) – Pavel Anikhouski Aug 09 '19 at 17:14
  • I'm unable to replicate your problem. What version of powershell are you using? The only reason the console should "hang" is if you're using the `-Wait` parameter. Also, are you using the actual console or the ISE / other dev tool? – Maximilian Burszley Aug 09 '19 at 17:38
  • 1
    @TheIncorrigible1, after running $p = Start-Process test.exe -RedirectStandardOutput .\out.txt -PassThru are you able to input anything, like $p to print out the process information? I am using the the pure powershell console, not ISE or other stuff. Name Value ---- ----- PSVersion 5.1.18362.145 PSEdition Desktop – xinglong Aug 09 '19 at 17:47

0 Answers0