Prevent the command prompt closing automatically

October 2016

If you suddenly see the automatic closure of your command prompt then revoke a command from the Start point and select the Run option in your operating system. Then open a command prompt window by keying CMD at the Start and the Run option. Now enter a command in the open window. By typing cmd /k, the /k option makes the shell stay open after command execution. Sometimes it is possible to change the features of the command prompt's action into the registry, because causing it to remain for input prior to closing is impractical. Thee "press any key to continue" prompts are programmed from the programs/scripts themselves, not CMD. You may consider rewriting every program to add that prompt, to get your desired results.

Sometimes, you will find that the command prompt window closes automatically when you don't want it to.

To address this problem:
  • Press Windows key + R to open the Run window
  • Launch the command prompt by typing:
     cmd /K
    • Adding / K after the command keeps the window open
    • You can then close the window manually when you no longer need it to be open .

Try, for example:
cmd /k tracert

Related :

This document entitled « Prevent the command prompt closing automatically » from CCM ( is made available under the Creative Commons license. You can copy, modify copies of this page, under the conditions stipulated by the license, as this note appears clearly.