On Exit Do Command
Posted: 07 Feb 2010 20:32
Is there any code that does a command when the executor closes the .bat file with the red X?If so, PLEASE post it below!
aGerman wrote:No, you can't.
Also you can't disable Ctrl+C.
Why do you need it?
Regards
aGerman
avery_larry wrote:Actually, start /wait /b will disable Ctrl+C for the duration of that particular command.
aGerman wrote:- which key is pressed
Code: Select all
@ECHO OFF
TITLE Keyboard Simulator
MODE CON cols=41 lines=5
:a
SET q1=
SET q2=
SET w1=
SET w2=
SET e1=
SET e2=
SET r1=
SET r2=
SET t1=
SET t2=
SET y1=
SET y2=
SET u1=
SET u2=
SET i1=
SET i2=
SET o1=
SET o2=
SET p1=
SET p2=
SET a1=
SET a2=
SET s1=
SET s2=
SET d1=
SET d2=
SET f1=
SET f2=
SET g1=
SET g2=
SET h1=
SET h2=
SET j1=
SET j2=
SET k1=
SET k2=
SET l1=
SET l2=
SET z1=
SET z2=
SET x1=
SET x2=
SET c1=
SET c2=
SET v1=
SET v2=
SET b1=
SET b2=
SET n1=
SET n2=
SET m1=
SET m2=
SET x11x=
SET x12x=
SET x21x=
SET x22x=
SET x31x=
SET x32x=
SET x41x=
SET x42x=
SET x51x=
SET x52x=
SET x61x=
SET x62x=
SET x71x=
SET x72x=
SET x81x=
SET x82x=
SET x91x=
SET x92x=
SET x01x=
SET x02x=
IF %ERRORLEVEL%==1 (
SET q1=[
SET q2=]
)
IF %ERRORLEVEL%==2 (
SET w1=[
SET w2=]
)
IF %ERRORLEVEL%==3 (
SET e1=[
SET e2=]
)
IF %ERRORLEVEL%==4 (
SET r1=[
SET r2=]
)
IF %ERRORLEVEL%==5 (
SET t1=[
SET t2=]
)
IF %ERRORLEVEL%==6 (
SET y1=[
SET y2=]
)
IF %ERRORLEVEL%==7 (
SET u1=[
SET u2=]
)
IF %ERRORLEVEL%==8 (
SET i1=[
SET i2=]
)
IF %ERRORLEVEL%==9 (
SET o1=[
SET o2=]
)
IF %ERRORLEVEL%==10 (
SET p1=[
SET p2=]
)
IF %ERRORLEVEL%==11 (
SET a1=[
SET a2=]
)
IF %ERRORLEVEL%==12 (
SET s1=[
SET s2=]
)
IF %ERRORLEVEL%==13 (
SET d1=[
SET d2=]
)
IF %ERRORLEVEL%==14 (
SET f1=[
SET f2=]
)
IF %ERRORLEVEL%==15 (
SET g1=[
SET g2=]
)
IF %ERRORLEVEL%==16 (
SET h1=[
SET h2=]
)
IF %ERRORLEVEL%==17 (
SET j1=[
SET j2=]
)
IF %ERRORLEVEL%==18 (
SET k1=[
SET k2=]
)
IF %ERRORLEVEL%==19 (
SET l1=[
SET l2=]
)
IF %ERRORLEVEL%==20 (
SET z1=[
SET z2=]
)
IF %ERRORLEVEL%==21 (
SET x1=[
SET x2=]
)
IF %ERRORLEVEL%==22 (
SET c1=[
SET c2=]
)
IF %ERRORLEVEL%==23 (
SET v1=[
SET v2=]
)
IF %ERRORLEVEL%==24 (
SET b1=[
SET b2=]
)
IF %ERRORLEVEL%==25 (
SET n1=[
SET n2=]
)
IF %ERRORLEVEL%==26 (
SET m1=[
SET m2=]
)
IF %ERRORLEVEL%==27 (
SET x11x=[
SET x12x=]
)
IF %ERRORLEVEL%==28 (
SET x21x=[
SET x22x=]
)
IF %ERRORLEVEL%==29 (
SET x31x=[
SET x32x=]
)
IF %ERRORLEVEL%==30 (
SET x41x=[
SET x42x=]
)
IF %ERRORLEVEL%==31 (
SET x51x=[
SET x52x=]
)
IF %ERRORLEVEL%==32 (
SET x61x=[
SET x62x=]
)
IF %ERRORLEVEL%==33 (
SET x71x=[
SET x72x=]
)
IF %ERRORLEVEL%==34 (
SET x81x=[
SET x82x=]
)
IF %ERRORLEVEL%==35 (
SET x91x=[
SET x92x=]
)
IF %ERRORLEVEL%==36 (
SET x01x=[
SET x02x=]
)
CLS
ECHO.%x11x%1%x12x% %x21x%2%x22x% %x31x%3%x32x% %x41x%4%4%x42x% %x51x%5%x52x% %x61x%6%x62x% %x71x%7%x72x% %x81x%8%x82x% %x91x%9%x92x% %x01x%0%x02x%
ECHO. %q1%Q%q2% %w1%W%w2% %e1%E%e2% %r1%R%r2% %t1%T%t2% %y1%Y%y2% %u1%U%u2% %i1%I%i2% %o1%O%o2% %p1%P%p2%
ECHO. %a1%A%a2% %s1%S%s2% %d1%D%d2% %f1%F%f2% %g1%G%g2% %h1%H%h2% %j1%J%j2% %k1%K%k2% %l1%L%l2%
ECHO. %z1%Z%z2% %x1%X%x2% %c1%C%c2% %v1%V%v2% %b1%B%b2% %n1%N%n2% %m1%M%m2%
CHOICE /C qwertyuiopasdfghjklzxcvbnm1234567890 /N > nul
GOTO a
Code: Select all
@echo off
TITLE Keyboard Simulator
MODE CON cols=41 lines=6
set ERRL=0
:a
SET q1=
SET q2=
SET w1=
SET w2=
SET e1=
SET e2=
SET r1=
SET r2=
SET t1=
SET t2=
SET y1=
SET y2=
SET u1=
SET u2=
SET i1=
SET i2=
SET o1=
SET o2=
SET p1=
SET p2=
SET a1=
SET a2=
SET s1=
SET s2=
SET d1=
SET d2=
SET f1=
SET f2=
SET g1=
SET g2=
SET h1=
SET h2=
SET j1=
SET j2=
SET k1=
SET k2=
SET l1=
SET l2=
SET z1=
SET z2=
SET x1=
SET x2=
SET c1=
SET c2=
SET v1=
SET v2=
SET b1=
SET b2=
SET n1=
SET n2=
SET m1=
SET m2=
SET x11x=
SET x12x=
SET x21x=
SET x22x=
SET x31x=
SET x32x=
SET x41x=
SET x42x=
SET x51x=
SET x52x=
SET x61x=
SET x62x=
SET x71x=
SET x72x=
SET x81x=
SET x82x=
SET x91x=
SET x92x=
SET x01x=
SET x02x=
IF %ERRL%==1 (
SET q1=[
SET q2=]
)
IF %ERRL%==2 (
SET w1=[
SET w2=]
)
IF %ERRL%==3 (
SET e1=[
SET e2=]
)
IF %ERRL%==4 (
SET r1=[
SET r2=]
)
IF %ERRL%==5 (
SET t1=[
SET t2=]
)
IF %ERRL%==6 (
SET y1=[
SET y2=]
)
IF %ERRL%==7 (
SET u1=[
SET u2=]
)
IF %ERRL%==8 (
SET i1=[
SET i2=]
)
IF %ERRL%==9 (
SET o1=[
SET o2=]
)
IF %ERRL%==10 (
SET p1=[
SET p2=]
)
IF %ERRL%==11 (
SET a1=[
SET a2=]
)
IF %ERRL%==12 (
SET s1=[
SET s2=]
)
IF %ERRL%==13 (
SET d1=[
SET d2=]
)
IF %ERRL%==14 (
SET f1=[
SET f2=]
)
IF %ERRL%==15 (
SET g1=[
SET g2=]
)
IF %ERRL%==16 (
SET h1=[
SET h2=]
)
IF %ERRL%==17 (
SET j1=[
SET j2=]
)
IF %ERRL%==18 (
SET k1=[
SET k2=]
)
IF %ERRL%==19 (
SET l1=[
SET l2=]
)
IF %ERRL%==20 (
SET z1=[
SET z2=]
)
IF %ERRL%==21 (
SET x1=[
SET x2=]
)
IF %ERRL%==22 (
SET c1=[
SET c2=]
)
IF %ERRL%==23 (
SET v1=[
SET v2=]
)
IF %ERRL%==24 (
SET b1=[
SET b2=]
)
IF %ERRL%==25 (
SET n1=[
SET n2=]
)
IF %ERRL%==26 (
SET m1=[
SET m2=]
)
IF %ERRL%==27 (
SET x11x=[
SET x12x=]
)
IF %ERRL%==28 (
SET x21x=[
SET x22x=]
)
IF %ERRL%==29 (
SET x31x=[
SET x32x=]
)
IF %ERRL%==30 (
SET x41x=[
SET x42x=]
)
IF %ERRL%==31 (
SET x51x=[
SET x52x=]
)
IF %ERRL%==32 (
SET x61x=[
SET x62x=]
)
IF %ERRL%==33 (
SET x71x=[
SET x72x=]
)
IF %ERRL%==34 (
SET x81x=[
SET x82x=]
)
IF %ERRL%==35 (
SET x91x=[
SET x92x=]
)
IF %ERRL%==36 (
SET x01x=[
SET x02x=]
)
CLS
ECHO.%x11x%1%x12x% %x21x%2%x22x% %x31x%3%x32x% %x41x%4%4%x42x% %x51x%5%x52x% %x61x%6%x62x% %x71x%7%x72x% %x81x%8%x82x% %x91x%9%x92x% %x01x%0%x02x%
ECHO. %q1%Q%q2% %w1%W%w2% %e1%E%e2% %r1%R%r2% %t1%T%t2% %y1%Y%y2% %u1%U%u2% %i1%I%i2% %o1%O%o2% %p1%P%p2%
ECHO. %a1%A%a2% %s1%S%s2% %d1%D%d2% %f1%F%f2% %g1%G%g2% %h1%H%h2% %j1%J%j2% %k1%K%k2% %l1%L%l2%
ECHO. %z1%Z%z2% %x1%X%x2% %c1%C%c2% %v1%V%v2% %b1%B%b2% %n1%N%n2% %m1%M%m2%
CHOICE /C:qwertyuiopasdfghjklzxcvbnm1234567890 /N > nul
set ERRL=%errorlevel%
GOTO a
Stergioss wrote:Major wrong!
BAT Beginner wrote:But i was wondering, how to you make sounds like you did with the keyboard batch?
Code: Select all
@echo off
:beep
cls
echo
ping -n 2 localhost>nul
goto beep
aGerman wrote:Hmm, try to detect F1 - F12, Print, Insert, Del, Shift, Ctrl, Alt, Arrows ...
And try if another window is focussed ...
BAT Beginner wrote:Ok All those codes are Awesome
But i was wondering, how to you make sounds like you did with the keyboard batch?
I would really love that kind of code.
aGerman wrote:IF %ERRL%==1 (
SET q1=[
SET q2=]
Echo Beep Icon Here(Too lazy to Copy paste!
)