Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I suppress the "terminate batch job" in cmd.exe [closed]

Tags:

batch-file

cmd

I'm looking for a mechanism for suppressing the "Terminate batch job? (Y/N)" invitation that I get whenever I press CTRL-C in a program started from a batch file:

batch file: jsshell.bat:

@echo off java -jar build-scripts\contrib\rhino1.7R1.jar 

and then starting it on cmd shell by:

> jsshell.bat 

which gives me a shell that can be exited by CTRL-C but after invoking CTRL-C I get a "Terminate batch job (Y/N)?" message which is nasty and annoying. How can I get it to just exit without me having to press 'y'?

like image 391
cellcortex Avatar asked Aug 05 '09 17:08

cellcortex


People also ask

How do I stop a batch from closing?

Add a pause statement to a batch file If you're creating a batch file and want the MS-DOS window to remain open, add PAUSE to the end of your batch file. This prompts the user to Press any key. Until the user presses any key, the window remains open instead of closing automatically.

How do I pause a batch file after execution?

Execution of a batch script can also be paused by pressing CTRL-S (or the Pause|Break key) on the keyboard, this also works for pausing a single command such as a long DIR /s listing. Pressing any key will resume the operation.

How do I stop a batch file from command line?

Windows. Once a command is launched from the GenRocket batch command, the user may terminate the command by pressing Ctrl+C or Ctrl+Break. Once the termination is initiated, the DOS command interpreter presents the user with the option to terminate the batch with either a Y or N option.


2 Answers

At this site, I finally found an effective solution:

script.cmd < nul 

To not have to type this out every time I made a second script called script2.cmd in the same folder with the line above. You may want to reverse the names. Works for me, but tested so far on XP only.

like image 102
Gringo Suave Avatar answered Oct 03 '22 12:10

Gringo Suave


The behaviour is implemented in the cmd.exe source code, and isn't possible to turn off without modifying cmd.exe. However you can modify cmd.exe to not show the message.

like image 20
WireGuy Avatar answered Oct 03 '22 11:10

WireGuy