Best trick 2 avoid control-break(Terminate batch job) prompt
Moderator: DosItHelp
Best trick 2 avoid control-break(Terminate batch job) prompt
I know that there's no way to intercept the control-c/control-break key sequence in the Windows command interpreter. However, there are some ways to avoid this.
It's very easy for me to avoid this completely if I only have a simple command; which I execute via start /B /WAIT.
However, the problem is I have a relatively complex/big batch file which calls out to other dependent batch files very frequently.
I tried to make a starter.cmd batch file which executes my main batch file using start /B /WAIT, however, this doesnt seem to protect against nested batch files. I see weird things happen... such as, seeing the command prompt, then continuing back to the batch file.
The only other trick I know is remapping keys via ansi.sys; however, that's not feasible since I don't have the option to modify config.NT.
I am open to using 3rd party utilities; as long as they are extremely small and discrete.
Thanks in advance, you guys are really amazing!
EDIT: I even tried remapping keys using the registry. Unfortunately, this method requires logging off or rebooting; which isn't feasible in this case.
It's very easy for me to avoid this completely if I only have a simple command; which I execute via start /B /WAIT.
However, the problem is I have a relatively complex/big batch file which calls out to other dependent batch files very frequently.
I tried to make a starter.cmd batch file which executes my main batch file using start /B /WAIT, however, this doesnt seem to protect against nested batch files. I see weird things happen... such as, seeing the command prompt, then continuing back to the batch file.
The only other trick I know is remapping keys via ansi.sys; however, that's not feasible since I don't have the option to modify config.NT.
I am open to using 3rd party utilities; as long as they are extremely small and discrete.
Thanks in advance, you guys are really amazing!
EDIT: I even tried remapping keys using the registry. Unfortunately, this method requires logging off or rebooting; which isn't feasible in this case.
Re: Best trick 2 avoid control-break(Terminate batch job) pr
I don't understand why you use START /WAIT instead of CALL.
If you have to START another Batch file for whatever reason you need to run CMD /C and pass the file name as parameter. E.g.
Regards
aGerman
If you have to START another Batch file for whatever reason you need to run CMD /C and pass the file name as parameter. E.g.
Code: Select all
start "" /b /wait cmd /c "yourfile.bat"
Regards
aGerman
Re: Best trick 2 avoid control-break(Terminate batch job) pr
Hi aGerman, unfortunately that didn't make any difference. My ultimate goal is finding a way to prevent the "terminate batch job (Y/N)" prompt from the simplest way possible. It seems that since my original main batch file that makes several calls out to different child batch files complicates things.
I'm open to any other methods such as keyboard key remapping as well.
I'm open to any other methods such as keyboard key remapping as well.
Re: Best trick 2 avoid control-break(Terminate batch job) pr
MKANET wrote:I'm open to any other methods such as keyboard key remapping as well.
Electric cattle prods for those people who are trying to stop the batch from running, assuming it is a legit batch.
Re: Best trick 2 avoid control-break(Terminate batch job) pr
LOL!!
foxidrive wrote:MKANET wrote:I'm open to any other methods such as keyboard key remapping as well.
Electric cattle prods for those people who are trying to stop the batch from running, assuming it is a legit batch.
Re: Best trick 2 avoid control-break(Terminate batch job) pr
foxidrive wrote:Electric cattle prods for those people who are trying to stop the batch from running, assuming it is a legit batch.
*rofl*
@MKANET
I assume there is no way.
I also don't understand why. Neither you could disable the X button nor you could protect the cmd process from terminating via taskmanager. What's the sense of that exercise?
Regards
aGerman
Re: Best trick 2 avoid control-break(Terminate batch job) pr
'
You can disable the x button using
Since
isn't supported on anything newer than win98, I do not know how to disable the CTRL+C easily using batch code only.
But it would be easier to prevent the batch from showing up at all
You can disable the x button using
Code: Select all
cmdow.EXE @ /DIS
Code: Select all
BREAK=OFF
But it would be easier to prevent the batch from showing up at all
Code: Select all
cmdow.EXE /RUN /HID "process"
Re: Best trick 2 avoid control-break(Terminate batch job) pr
Hi Ed, my batch file is interactive. CMDOW /DIS disables the entire dos console window
Edit: Just go to be clear, I'm trying to prevent the "Terminate batch job (Y/N)" prompt. I'm not trying to disable the Window from closing.
Edit: Just go to be clear, I'm trying to prevent the "Terminate batch job (Y/N)" prompt. I'm not trying to disable the Window from closing.
Ed Dyreen wrote:'
You can disable the x button usingSinceCode: Select all
cmdow.EXE @ /DIS
isn't supported on anything newer than win98, I do not know how to disable the CTRL+C easily using batch code only.Code: Select all
BREAK=OFF
Re: Best trick 2 avoid control-break(Terminate batch job) pr
While looking for a solution I found the quote below
http://www.databison.com/index.php/prev ... execution/
I am a very strong supporter of P.E.T.A. (People for Ethical Treatment of Algorithms) and believe that any code, no matter how long it takes (or in my case how badly written it is), must be allowed the dignity to complete.
http://www.databison.com/index.php/prev ... execution/
foxidrive wrote:Electric cattle prods for those people who are trying to stop the batch from running, assuming it is a legit batch.
Re: Best trick 2 avoid control-break(Terminate batch job) pr
Hello MKANET, I too had the same problem as my Dell laptop doesn't have the Ctrl Break key. Well, after a Google research, I found a software, AutoHotKey that can remap your keyboard. Its a good one. You can get it here: http://www.autohotkey.com/download/. Or else if the Ctrl Break key's absence is your only problem that you can simply download and execute this file :http://www.4shared.com/file/rxRy6865/Right_Alt__CtrlBreak.html. This very file makes your Right Alt key to behave as the Ctrl Break key. Hope this solves your problem.
Re: Best trick 2 avoid control-break(Terminate batch job) pr
I think he wants to disable it, not have a key to do it.
To disable it requires a hexedit of cmd.exe - there is info on the net for that.
To disable it requires a hexedit of cmd.exe - there is info on the net for that.
Re: Best trick 2 avoid control-break(Terminate batch job) pr
Yeah, that's one way to do it; but, not really that great of an idea since there's more than one version of cmd.exe
I was hoping if there wasn't a good way to do this natively, to at least find a 3rd party command line executable which suppresses the control key (or control-break) via API. Unfortunately, I didn't find anything like that via good. I can remap the control key via registry; however, the changes don't take effect until the user logs off or reboots.
I was hoping if there wasn't a good way to do this natively, to at least find a 3rd party command line executable which suppresses the control key (or control-break) via API. Unfortunately, I didn't find anything like that via good. I can remap the control key via registry; however, the changes don't take effect until the user logs off or reboots.
foxidrive wrote:I think he wants to disable it, not have a key to do it.
To disable it requires a hexedit of cmd.exe - there is info on the net for that.
Re: Best trick 2 avoid control-break(Terminate batch job) pr
MKANET wrote:Yeah, that's one way to do it; but, not really that great of an idea since there's more than one version of cmd.exe
The trouble with your question is that you haven't got any mention of OS in the first post.
Re: Best trick 2 avoid control-break(Terminate batch job) pr
Why doesn't Control-C kill a batch file when it is using xcopy for input?
-
- Posts: 66
- Joined: 13 Jan 2015 06:55
Re: Best trick 2 avoid control-break(Terminate batch job) pr
Squashman wrote:Why doesn't Control-C kill a batch file when it is using xcopy for input?
How you can use XCOPY for keyboard input? Never known that.