How to disable CTRL + C in batch?

2

Is it possible to disable the CTRL + C batch command?

    
asked by anonymous 30.04.2018 / 23:42

3 answers

0
  

Yes and No!

     

By default, in Batch there is no way to bar Ctrl + C but it is possible   disable these keys with some external "utility" , written in a   programming language, but I do not know any, but it is possible if there is any.

    
01.05.2018 / 02:08
0

In windows 10 it is possible to change the properties, first open the prompt in Administrator mode, then right click on the title of the prompt and go to properties and disable the option for ctrl:

    
01.05.2018 / 02:34
0

Another option would be a script like the one below, adapt it to your needs:

This batch file can not be canceled by Ctrl-C, and if it is canceled by Ctrl-Break, the cmd.exe window will be closed.

@echo off
setlocal

if "%~1" equ "NonCancelable" goto NonCancelable
start "" /B cmd /C "%~F0" NonCancelable
exit

:NonCancelable
echo You can NOT cancel me!
echo/
set "var="
set /P "var=Enter password (enter Exit to end): "
if /I "%var%" neq "exit" goto :NonCancelable
echo Terminating non cancelable...
pause
exit

Original: link

    
01.05.2018 / 03:24