SlothLovesChunk
SlothLovesChunk

Reputation: 75

Batch File - Choice Options - Setting Default Option

In my example batch file below, I have a few options for the user to select from. In addition, I would like to set a default option. For example, I'd like the user to be able to hit hit [ENTER] and it select the default option (of my choosing) from my list (let's say option 1).

Thanks for the help!

@ECHO OFF
:selector
set input=
ECHO 1. Option 1
ECHO 2. Option 2
ECHO 3. Option 3
set /p input=Select an option number above:
if %input%==1 goto 1
if %input%==2 goto 2
if %input%==3 goto 3

@REM Invalid Choice Message
@echo Not a valid choice
goto selector

:1
echo you picked 1
pause
goto end

:2
echo you picked 2
pause
goto end

:3
echo you picked 3
pause
goto end

:end

Upvotes: 4

Views: 2867

Answers (1)

RGuggisberg
RGuggisberg

Reputation: 4750

change set input= to set input=1

Upvotes: 3

Related Questions