Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

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?

share|improve this question
    
Can you be a bit more specific as to which application you are running at the command prompt that is crashing? –  heavyd Feb 17 '10 at 0:50
    
I've had this problem with various applications for years. Sometimes its a standalone program, sometimes its a program I wrote myself within an IDE –  Casebash Feb 17 '10 at 0:56
    
Just to clarify, as this is relatively often misinterpretation. Is the cmd crashing (you get a windows dialog: cmd has crashed ... send error report ...) or are you executing some program in it and it executes so fast and then closes, that you cannot see the result of the program ? –  ldigas Feb 17 '10 at 2:18
    
@Idigas: I should have been clearer. The application is crashing, not the prompt. –  Casebash Feb 17 '10 at 3:55
1  
Here's a bunch of workarounds, but no one has a solution: computerhope.com/issues/ch000738.htm It should really pause by default when the command prompt is finished, and allow you to read the error. Is there any way to make this happen with all command prompts? Can the command prompt executable be replaced with something nicer? –  endolith Feb 28 '11 at 20:21

2 Answers 2

up vote 1 down vote accepted

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.

share|improve this answer
    
If manually entering the path of the program is too painful we can use the method here: superuser.com/questions/98322/… –  Casebash Feb 17 '10 at 21:58
    
While a configuration setting to stop the console closing on error would be ideal, this solution is good enough to be workable. –  Casebash Feb 17 '10 at 22:00
1  
@Case: Well, the problem is that the console window is tied to the process. Once that process terminates, the window disappears, just as a GUI window disappears if its owning application closes. That's actually a design choice I think. PIF shortcuts in Windows 9x behaved otherwise and could be told to remain open after the program exited. But that was an entirely different thing architecture-wise. Visual C++ 6 apparently automatically ran the program with cmd /c foo.exe && pause so there was a prompt at the end. Something I actually liked but VS2k8 doesn't have such an option. Sadly. –  Joey Feb 18 '10 at 2:39

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.

share|improve this answer
    
This is my situation. I run the program from the command line, the program opens another command prompt, which immediately closes with an error I can't read. The command prompt that remains open doesn't show any errors. –  Buttons840 Jul 13 '12 at 17:06

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.