1

Is there a way to monitor the output of a command prompt without redirecting its output to a stream reader so that it can be detected if error messages display in it? I'm using C#.

chamilad
  • 1,619
  • 3
  • 23
  • 40
  • Just to confirm, you definitely mean a command prompt? I.e. the interactive `cmd.exe` program where user can enter commands? Not just another application that has stdin, stdout? – Kieren Johnstone Oct 21 '11 at 07:43
  • http://stackoverflow.com/questions/1390559/how-to-get-the-output-of-a-system-diagnostics-process – dknaack Oct 21 '11 at 07:45
  • Yup, a cmd.exe with additional input parameters concerned with env variables etc. – chamilad Oct 21 '11 at 07:46

2 Answers2

1

Simple answer: No.

If you need the console output of a program you have to redirect its output stream.

Oliver
  • 43,366
  • 8
  • 94
  • 151
  • 1
    That is a lie. If process is attached to cmd console It will receive console output and will be able to display text on It. – Tadeusz Oct 21 '11 at 08:02
  • And how do you attach a process to a cmd console? By redirecting its input and output streams. So where is the lie? – Oliver Oct 21 '11 at 09:57
1

You must use AttachConsole for cmd.exe process.

Tadeusz
  • 6,453
  • 9
  • 40
  • 58