Computing.Net > Forums > Disk Operating System > Disable CTRL C in batch files

Computer Problems? Computing.Net has over 1,000,000 posts about all things technology related! Over 90% answered within 24 hours! Click here to start participating now! Also, be sure to check out the New User Guide.

Disable CTRL C in batch files

Reply to Message Icon

Name: STING007
Date: April 21, 2001 at 23:18:05 Pacific
Comment:

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!



Sponsored Link
Ads by Google

Response Number 1
Name: Laurence
Date: April 22, 2001 at 01:29:02 Pacific
Reply:

Batfiles: The DOS batch file programming handbook

Go here:
http://ftpsearch.lycos.com/?form=medium

and search for:
kystp110.zip


0

Response Number 2
Name: .
Date: April 22, 2001 at 01:34:58 Pacific
Reply:

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
ret

And 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


0

Response Number 3
Name: DoOMsdAY
Date: April 22, 2001 at 08:51:11 Pacific
Reply:

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).


0

Response Number 4
Name: Mike
Date: April 22, 2001 at 09:07:27 Pacific
Reply:

break = off is off by default, most people don't turn it on.


0

Response Number 5
Name: STING007
Date: April 22, 2001 at 23:45:41 Pacific
Reply:

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!


0

Related Posts

See More



Response Number 6
Name: DoOMsdAY
Date: April 23, 2001 at 16:38:45 Pacific
Reply:

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.)


0

Sponsored Link
Ads by Google
Reply to Message Icon






Post Locked

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


Go to Disk Operating System Forum Home


Sponsored links

Ads by Google


Results for: Disable CTRL C in batch files

Variables in batch files www.computing.net/answers/dos/variables-in-batch-files/12289.html

What does the % mean in batch files? www.computing.net/answers/dos/what-does-the-mean-in-batch-files/5925.html

Delay in batch files w/o 3rd party www.computing.net/answers/dos/delay-in-batch-files-wo-3rd-party/13475.html