Tom's Guide | Tom's Hardware | Tom's Games
![]() |
![]() |
![]() |
Hi
Ok i would just like to know the correct programming on how to disable ctrl c in a batch file. I seen many programs that do this but what is the actual batch programming for it so i can add it in a batch file without the use of the other program. Please let me know via email!

The command "break off" can be a good start, if you simply want to disable Ctrl+C just to prevent aborting disk read and write operations.
If you want to disable it also for console input and output, you should write a tool, because this depends on the structure of the standard input, output and error devices.You can chose to write or two simple debug scripts or two simple .com files.
Anyway, the code is the following.
To disable Ctrl+C:
mov ax,4400
mov bx,0
int 21
mov ax,4401
or dx,20
int 21
retAnd this is the code to restore the original status (do it as soon as you can: it's better if you change and restore the status for every console command in the batch file, more than changing the state of the device at the beginning and restoring it at the end):
mov ax,4400
mov bx,0
int 21
mov ax,4401
and dx,ffdf
int 21
ret

Don't forget about Ctrl+Break. I used to remap 'c' and 'C' to nothing to prevent Ctrl+C (via ansi.sys), but Ctrl+Break would still work. Also in Pascal I remapped the break vector (as the above ASM code does by 'the guy with no name'), but that also didn't take care of Ctrl+Break. However perhaps the interrupts you're changing are different than the ones I was - dunno, I did that probably 4 years ago now. :) Another dangerous way to achieve this is via a 'ctty nul'. It redirects all output and takes all input from the NUL device - or nothing. You can redirect to CON for ECHOs if you want to communicate with the user, but if for some reason something halts, there is no way to escape (except a quick reboot).

Ok i explain more clearly!!!
I DO NOT want the program that does this method. I actually want the batch programming for it. the actual batch file and not another COM or EXE file that does it for you.Please help this way, thanx!

That's why I suggested the 'ctty nul'. That is a standard DOS command that one can do on any properly installed MS-DOS machine. (Dunno what versions it is available from.)

![]() |
![]() |
![]() |

This post is quite old and has been locked from receiving new replies. Please create a new posting instead.
| Ads by Google |