Exit Batch File and CMD With One Keypress Not Hitting ENTER After
Posted: 29 Apr 2022 10:55
I'm trying to do one of the following:
A) Press ESC to exit the batch file and CMD without pressing enter (Preferred)
B) Press one specific key and immediately exit the batch file and CMD without having to press enter
I've tried a few things so far and the code below exits but I still have to press enter after typing "-". How can
I just press "-" by itself, not press enter, and have it exit the batch file and CMD? (I'm open to changing the key
I press to exit.)
I appreciate any help!
A) Press ESC to exit the batch file and CMD without pressing enter (Preferred)
B) Press one specific key and immediately exit the batch file and CMD without having to press enter
I've tried a few things so far and the code below exits but I still have to press enter after typing "-". How can
I just press "-" by itself, not press enter, and have it exit the batch file and CMD? (I'm open to changing the key
I press to exit.)
Code: Select all
ECHO.
ECHO 1) I like Mickey Mouse
ECHO 2) I like Minnie Mouse
ECHO 3) I like Donald Duck
ECHO.
SET /P M=Press 1, 2,or 3 then press ENTER
IF %M%==1 GOTO MICKEY
IF %M%==2 GOTO MINNIE
IF %M%==3 GOTO DONALD
IF %M%==- EXIT /B