@ECHO OFF IF "%~4"=="" GOTO Syntax ECHO.%* | FIND "/?" >NUL && GOTO Syntax SETLOCAL ENABLEDELAYEDEXPANSION SET SecondChoice= SET Message= SET Default= SET Index=-1 FOR %%A IN (%*) DO ( IF !Index! EQU -1 ( SET Message=%%~A ) ELSE ( IF !Index! EQU 0 ( SET Default=%%~A ) ELSE ( SET Selected.!Index!=%%~A ) ) SET /A Index += 1 ) :Again SET Selected=%Default% CLS ECHO. ECHO.%Message% FOR /L %%A IN (1,1,3) DO ( ECHO. IF "%%~A"=="%Selected%" ( ECHO %%A. !Selected.%%~A! ^(default^) ) ELSE ( ECHO %%A. !Selected.%%~A! ) ) ECHO. SET /P Selected= IF "!Selected.%Selected%!"=="" GOTO :Again SET SecondChoice=!Selected.%Selected%! ENDLOCAL & SET SecondChoice=%SecondChoice%& EXIT /B %Selected% GOTO:EOF :Syntax ECHO. ECHO SecondChoice.bat, Version 1.00 for Windows XP and later ECHO Present a list of choices, and wait for the user to either pick ECHO a choice by number or to press Enter for the default choice ECHO. ECHO Usage: SecondChoice "prompt" default "first" "second" [ "third" [ ... ] ] ECHO. ECHO Where: "prompt" is the message to be displayed above the list of choices ECHO default is the index of the default choice in the list ECHO "first" ... are the choices to be listed (minimal 2, maximal 8) ECHO. ECHO Notes: The list of choices will be presented until a valid choice is made. ECHO The text of the selected choice is saved in variable %%SecondChoice%% ECHO The index of the selected choice is returned as "errorlevel". ECHO In case of ^(command line^) errors, the returned "errorlevel" is 0. ECHO. ECHO Example: SecondChoice "Select speed:" 2 slow normal fast ECHO. ECHO Select speed: ECHO 1. slow ECHO 2. normal (default) ECHO 3. fast ECHO. ECHO Written by Rob van der Woude ECHO http://www.robvanderwoude.com EXIT /B 0