How to deactivate CTRL+C in batch?

Asked

Viewed 528 times

3

You can deactivate the CTRL+C command in batch?

3 answers

1

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

This batch file cannot 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: https://stackoverflow.com/a/36953316/935330

  • Thank you for your comment!

0

Yes and No !

by default, in the Batch there is no way to stop the Ctrl+C but it is possible disable these keys with some "utility" external, written in a programming language, but I don’t know any, but it is possible if there is any.

  • Thank you for your comment!

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: inserir a descrição da imagem aqui
(source: merabheja.with)

  • But then there won’t be any more shortcuts for Ctrl, right? unless this machine is a server and there is no need to use shortcuts, this option is good.

  • Thank you for your comment!

Browser other questions tagged

You are not signed in. Login or sign up in order to post.