Skip to content

Instantly share code, notes, and snippets.

@rtcoms
Forked from jcefoli/choice.bat
Created August 31, 2022 11:04
Show Gist options
  • Save rtcoms/1d194603ba74297c9d0d4257bc51dbcf to your computer and use it in GitHub Desktop.
Save rtcoms/1d194603ba74297c9d0d4257bc51dbcf to your computer and use it in GitHub Desktop.
Template for Yes/No Choice input in batch files
@ECHO OFF
:start
SET choice=
SET /p choice=Do something? [N]:
IF NOT '%choice%'=='' SET choice=%choice:~0,1%
IF '%choice%'=='Y' GOTO yes
IF '%choice%'=='y' GOTO yes
IF '%choice%'=='N' GOTO no
IF '%choice%'=='n' GOTO no
IF '%choice%'=='' GOTO no
ECHO "%choice%" is not valid
ECHO.
GOTO start
:no
ECHO Do all of the no things here!
PAUSE
EXIT
:yes
ECHO Do all of the yes things here!
PAUSE
EXIT
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment