I'm trying to get my head around how the termination of a batch file works.

As I know CTRL+C or CTRL+SHIFT+BREAK prompts the user with the message "Terminate batch job (Y/N)?"

From my reading pressing 'N' will continue the batch to the next command. However, pressing 'Y' just closes the batch file and returns to an open command prompt window. How can I get the command prompt window to close entirely from pressing the 'Y' option?

  • My first thought was to start your batch file as myfile.bat & exit, which, in theory, should run your batch file, and then once it is done, run the exit command to close the command prompt window. But it doesn't seem to work if the batch file is terminated with Ctrl+C. I'll keep fiddling with it, and maybe this will give someone else an idea. – Doug Deden Mar 26 at 15:55
  • Suggest you trap the errorlevel generated by the Y answer and if found, branch to closing the command prompt window. It's exit code 3221225786, aka 0xC000013A or STATUS_CONTROL_C_EXIT. as per stackoverflow.com/questions/25444765/… – K7AAY Mar 26 at 15:59

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.