Using Choice to get user interaction
1 March 2002 by Snakefoot | Comment » | Trackback OffMS DOS 6.0 introduced the program CHOICE, which can display a set of options and wait for the user to make a choice. When the user makes a selection the return code of CHOICE contains the selection, which can be accessed using ERRORLEVEL. This makes it possible to prompt the user for input from the command line in a batch file and react to it.
More Info MS KB Q96697
More Info MS KB Q97504
More Info MS KB Q77457choice /c:abc Choose an option
IF ERRORLEVEL 3 GOTO OPTIONC
IF ERRORLEVEL 2 GOTO OPTIONB
IF ERRORLEVEL 1 GOTO OPTIONA
:OPTIONC
ECHO C
GOTO EXIT
:OPTIONB
ECHO B
GOTO EXIT
:OPTIONA
ECHO A
GOTO EXIT
:EXIT
More Info MS KB Q96697
More Info MS KB Q97504
Updated: 23 September 2007