When I type Ctrl^C to stop a running windows script (.bat) from the windows command prompt, it gives me a prompt "Terminate batch job (Y/N)?". How can I remove this prompt?
Thanks
Remove the prompt “Terminate batch job (Y/N)?â€
Moderator: DosItHelp
Re: Remove the prompt “Terminate batch job (Y/N)?â€
I don't think you can.
Re: Remove the prompt “Terminate batch job (Y/N)?â€
You certainly can block the message, but I don't think it is very useful.
The message is sent to stdout, so if you redirect to nul, then you won't see the message. But then you don't see any output, and the user doesn't know to press Y to exit the script.
Try the following. I redirect the PAUSE command to stderr so that you still see the PAUSE message. Hit <Ctrl-C> instead of pressing <ENTER>, and you will not see any Ctrl-C prompt. If you enter Y then the script will terminate.
I have managed to make use of this effect in my routine to programattically abort a batch script immediately, and cleanly, no matter how many CALLs are active: http://stackoverflow.com/a/25474648/1012053
Dave Benham
The message is sent to stdout, so if you redirect to nul, then you won't see the message. But then you don't see any output, and the user doesn't know to press Y to exit the script.
Try the following. I redirect the PAUSE command to stderr so that you still see the PAUSE message. Hit <Ctrl-C> instead of pressing <ENTER>, and you will not see any Ctrl-C prompt. If you enter Y then the script will terminate.
Code: Select all
@echo off
>nul call :test
echo returned from :test
exit /b
:test
pause >&2
exit /b
I have managed to make use of this effect in my routine to programattically abort a batch script immediately, and cleanly, no matter how many CALLs are active: http://stackoverflow.com/a/25474648/1012053
Dave Benham