1

I'm trying to retrieve the standard output from a little command line tool that I wrote (in .NET too) by starting a process with it like this.

It works perfectly except if my command line tool tries to retrieve the Console.CursorTop property, or tries to set the Console.CursorVisible property. In those cases, it crashes.

I don't understand why this is happening, other methods or properties of Console might work but some like theses don't. Is there some kind of hidden Cursor object in Console that never get initialized if started that way?

This tool works fine if I launch it from the explorer or if I run it in a cmd.

Could someone explain me why it happens and how I can prevent it? Thanks.

Community
  • 1
  • 1
  • Are you sure that problem is in Console.CursorTop or CursorVisible properties? Have you tried isolating your problem to simple console application? This sample (http://ideone.com/MHi07K) seem to run without problems on local machine. – Alexander Apr 22 '14 at 15:28
  • You cannot refer to cursor properties when you forced the console mode app to run without a console, ProcessStartInfo.CreateNoWindow property. There is no cursor. Nor would you *want* to tinker with it, redirection cannot in any way deal with placement of text. Use the IsOutputRedirected helper function in [this answer](http://stackoverflow.com/a/3453272/17034) to avoid the crash and to make your output compatible with redirection. – Hans Passant Apr 22 '14 at 16:55

0 Answers0