Super User is a question and answer site for computer enthusiasts and power users. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

An .exe which is runs via cmd.exe runs and then quickly disappears before I can read the error message. How can I get the cmd.exe window and error message to not close? Or is there anyway to log that error info that just flashed? Thanks.

share|improve this question

Starting a program that launches console will indeed close the window, because CMD is no longer needed.

If you press start and type cmd and press enter, you will launch a command prompt.

Press the driveletter the program is on if this is not on C:, followed by a : and press enter.

In the below examples the _ at the end represents your cursor.




now, use the command cd to navigate to the directory of the program. You can press tab to autocomplete names. Tootab would make Tools if that folder exists.


D:\>cd Tools_

D:\Tools>cd "My Program"_   <- type 'My' and press tab to Autocomplete to "My Program"

D:\Tools\My Program>_

Now enter the name of the program you want to run.


D:\Tools\My Program>program_
Hello, I am the error message you want to see.

D:\Tools\My Program>_
share|improve this answer
you can use the /D switch to switch drive letters with cd so cd /D C:\Tools will always go to the directory no matter where you are currently – ratchet freak Jul 4 '14 at 11:01
I am aware, but I wanted to keep the post as simple as possible. – LPChip Jul 4 '14 at 11:21
Easier way : open the explorer, navigate to the directory and call "cmd" from the address bar. – Lyrkan Jul 4 '14 at 13:31
@LPChip It's a default feature of Windows 7/8 that works without any additional software. If you already opened the right path in the terminal there is an even more convenient way though: Shift + Right Click -> Open command window here – Kapep Jul 4 '14 at 13:50
Or even easier, open the command prompt, and drag and drop the program into it - Windows will insert the full path to the executable into the command prompt. Then just hit enter. – Moshe Jul 4 '14 at 13:52

Normally when I have to do this I create a bat file in the same folder (so new text file rename to whatever.bat) open in text folder then type:

Name of exe Pause

Close and save then run the bat file and it should keep it open!

share|improve this answer
Can you add some instructions on how to do this? An average user that knows how to make a .bat file would also know how to pause at the end. – LPChip Jul 4 '14 at 9:21

You can use .bat file to run that exe.

Also, you can use the following command in cmd to log the error/output of that exe file into a text file:

myFile.exe >> "C:\logFile.txt"

Double greater than symbol appends to the existing file " >> " however, single symbol overwrite the existing file ">".

Hope this will help you to log the error.

share|improve this answer
Actually, many programs print to stderr. >> will only log stdout. You need to add a 2>&1, e.g. command 2>&1 >>log.txt – Bob Jul 4 '14 at 14:19

You need to run it in an already-existing instance of cmd.exe. You can press and hold shift and right-click in a directory then click "Open command window here". Then either type the name of an exe or click and drag it into the command window, then press enter.

share|improve this answer

According to this:

|| [...] command1 || command2 Use to run the command following || only if the command preceding || fails. Cmd.exe runs the first command, and then runs the second command only if the first command did not complete successfully (receives an error code greater than zero).

and if you are making that .exe, you just need to put pause command after your sentences.

And example in c++ that call the bash:

#include <iostream>
#include <windows.h>

using namespace std;

int main()
    system("cd  akfhaskfn|| pause");
    system("cd  || pause");

    return 0;

You will see that only the first one will call the pause command.

share|improve this answer
Welcome to Super User! While this may answer the question, it would be a better answer if you could provide some explanation why it does so. – DavidPostill Aug 4 '15 at 7:21

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .