Best trick 2 avoid control-break(Terminate batch job) prompt

Discussion forum for all Windows batch related topics.

Moderator: DosItHelp

Message
Author
jeb
Expert
Posts: 1055
Joined: 30 Aug 2007 08:05
Location: Germany, Bochum

Re: Best trick 2 avoid control-break(Terminate batch job) pr

#16 Post by jeb » 23 Oct 2015 10:13

OperatorGK wrote:How you can use XCOPY for keyboard input? Never known that.


dostips: how to display password in asterisk

The main part to get a single character is done by

Code: Select all

Xcopy /W "%~f0" "%~f0" 2>Nul

The other stuff is to build a complete string and to handle things like !, & and backspace.

OperatorGK
Posts: 66
Joined: 13 Jan 2015 06:55

Re: Best trick 2 avoid control-break(Terminate batch job) pr

#17 Post by OperatorGK » 23 Oct 2015 11:33

jeb wrote:
OperatorGK wrote:How you can use XCOPY for keyboard input? Never known that.


dostips: how to display password in asterisk

The main part to get a single character is done by

Code: Select all

Xcopy /W "%~f0" "%~f0" 2>Nul

The other stuff is to build a complete string and to handle things like !, & and backspace.

Isn't this "pause >nul" trick? Or "xcopy" is a previous version?
Also, pause handles Ctrl+C properly. Dunno about why xcopy doesn't.

Fossil Tech
Posts: 1
Joined: 24 Oct 2015 01:28

Re: Best trick 2 avoid control-break(Terminate batch job) pr

#18 Post by Fossil Tech » 24 Oct 2015 01:43

This question is extremely old now, however, someone resurrected it 2015.

No need to HEX edit CMD.EXE etc... Someone mentioned a restart too(?)

The solution that I found to block CTRL+C aka Terminate Batch Y/N COMPLETELY.

No Fuss, No kidding, No Breaking Out. XOUT but that too can be disabled.

Briefly:

Code: Select all

C:\PROFILES\ADMIN>REN "%COMSPEC:~0,-8%\CSRSS.EXE" !!!CSRSS.!!!


OOPS Windows File Protection. If WFP is enabled ask almighty Google about that.

Transpose the file names to undo. WARNING: This MAY also break your toaster. 8)

PRO: Disallow all programs from injecting code via CSRSS hooking.

CON: PROPERTIES from the System Menu of CMD Windows are disabled as well.

CON: Enemy Territory will certainly whine until dialog box is dismissed once.

ELSE This is bulletproof. I'm being extremely terse!

=================================================================================

SideTip For KB Fans:

Code: Select all

COPY CON %SYSTEMROOT%\X.BAT

@EXIT

Hit ENTER after typing @EXIT then hit CTRL+Z then ENTER again.

Test drive it by typing the letter X at CMD Prompt & hit ENTER.

OperatorGK
Posts: 66
Joined: 13 Jan 2015 06:55

Re: Best trick 2 avoid control-break(Terminate batch job) pr

#19 Post by OperatorGK » 24 Oct 2015 12:10

Fossil Tech wrote:This question is extremely old now, however, someone resurrected it 2015.

No need to HEX edit CMD.EXE etc... Someone mentioned a restart too(?)

The solution that I found to block CTRL+C aka Terminate Batch Y/N COMPLETELY.

No Fuss, No kidding, No Breaking Out. XOUT but that too can be disabled.

Briefly:

Code: Select all

C:\PROFILES\ADMIN>REN "%COMSPEC:~0,-8%\CSRSS.EXE" !!!CSRSS.!!!


OOPS Windows File Protection. If WFP is enabled ask almighty Google about that.

Transpose the file names to undo. WARNING: This MAY also break your toaster. 8)

PRO: Disallow all programs from injecting code via CSRSS hooking.

CON: PROPERTIES from the System Menu of CMD Windows are disabled as well.

CON: Enemy Territory will certainly whine until dialog box is dismissed once.

ELSE This is bulletproof. I'm being extremely terse!

=================================================================================

SideTip For KB Fans:

Code: Select all

COPY CON %SYSTEMROOT%\X.BAT

@EXIT

Hit ENTER after typing @EXIT then hit CTRL+Z then ENTER again.

Test drive it by typing the letter X at CMD Prompt & hit ENTER.


Requires admin rights and we can't disable that. I don't think it's universal solution.

MrJeeves
Posts: 1
Joined: 18 Dec 2015 12:25

Re: Best trick 2 avoid control-break(Terminate batch job) prompt

#20 Post by MrJeeves » 18 Dec 2015 12:36

The following code suppresses the text and the ^C:

Code: Select all

start "" /wait "program.bat">nul | echo n>nul

Post Reply