2

Whenever a program in command prompt crashes on Windows it closes so fast that I can't see the error message that is displayed in the prompt. Is there any way to prevent this behaviour?

There are two different situations where this occurs. One is when I open a program I downloaded from the Internet. This is solved by opening up a prom[t first (although it is a pain to have to open a prompt and type in the address of the application.

The other case is when I am using an IDE. I use a variety (Eclipse, Netbeans, Visual Studio, ect). Perhaps I should ask this part of the question on Stack Overflow?

Casebash
  • 7,727

2 Answers2

1

For any program you can just open a command prompt and run the program from there; that's the obvious way.

If you're writing a program yourself you can put a Console.ReadLine() or so at the end which won't close the console window until Enter is hit. It's not too nice, though, so probably wrapping it into #ifdef DEBUG makes it nicer.

Anyway, for Eclipse it shouldn't be really necessary as Eclipse captures the console output of the program it runs (at least it does it for me with Java).

For Visual Studio you may consider using Debug.Print instead of Console.WriteLine for lines you really want to see.

For all cases of an own program you can also just dump crash information into a file.

Joey
  • 41,098
1

If (as it appears to me) you're running a program which opens a console window when it runs (and which is therefore closed when the program exits) then you need to find a way of running it from an existing Command Prompt window.
The program may still open another console window and crash, but you might get to see some output in your Command Prompt window.

njd
  • 11,426