I'm trying to run an iteration program, and whenever I click on it, it opens then terminates. When I open the input text file, using the program, the iteration completes, then the window instantly closes. How can I either run it so that the window does not close (and I can see my results), or manage to do the same thing in command prompt. I'm not super familiar with doing stuff in command prompt.

  • 1
    open a command prompt (Start -> Run -> cmd.exe), navigate to the location of your folder using the command prompt cd command, run the .exe from there
    – user13267
    Feb 12, 2015 at 11:05
  • 4
    Alternatively you can create a batch file (.bat) of two lines. First is your application's command line and the second one is "PAUSE". It will keep the command line window open 'till you press a key or close it using the "X" button. The advantage of this solution is that you can have a separate shortcut to the .bat file so you can either start your program with or without pausing at the finish.
    – mg30rg
    Feb 12, 2015 at 14:53
  • In a command prompt, type: your_cmd.exe&&pause
    – user418778
    Feb 14, 2015 at 0:30

7 Answers 7


This will leave the console window open even after MyApp.exe terminates:

cmd /K "C:\SomeFolder\MyApp.exe"

You can create a shortcut with the above. This solution works with all console programs and does not require you to go through Command Prompt every time (or modify the original exe which you usually can't).

Incidentally the /K switch has been around since NT days :-p


Another way, quite useful if the path to the .exe is a complicated one: Start the command prompt and then just drag the .exe file into the cmd window. The full path to the file will be pasted into the prompt and you just have to press enter. No need to cd into any paths.

  1. Open command prompt -> Got to your .exe's location using cd command -> execute your .exe
  2. You can add Console.ReadKey() at the end of your code so that program will wait until the user presses some key.

A way to run a file with cmd and have it stay open:

start /b /w /D"C:\StartAndEnd\scripts" NVIDIASystemMonitor.au3

The "/w" means it waits until the application closes.

If you are on 64bit there here is another example:

c:\windows\syswow64\cmd.exe /c c:\windows\sysnative\cmd.exe /c start /b /w /D"C:\StartAndEnd\scripts" NVIDIASystemMonitor.au3

This makes sure it still runs as 64bit.


Start menu -> cmd -> cd C:\PATHTOYOURFILE\ -> program.exe

Or add a pause function at the end of your iteration program (assuming you have access to the source)


To save the hassle of having to potentially cd into the correct folder when you're probably already there in windows explorer, simply hold shift, right click on any white space in the folder and click "Open command prompt window here" to open cmd with its directory already set. You can then just type the name of the exe itself

  • 2
    This would best be entered as a comment, as it does not answer the original question. It is a useful tip, however. Feb 12, 2015 at 23:57

Might want to try a redirect too. I think this is so simple and also adds a persistence to the output message that is non-volatile. c:\myapp.exe > c:\myapp.dbg

You must log in to answer this question.

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