Use environment variables for user input in Windows NT

It can be useful sometimes to provide the user with a choice when running batch file from the command prompt (cmd.exe). This can be done with this command that prompts the user for input from the console and saves it in an environment variable:

set /p your_choice=”Please enter your choice (1,2,3): “
if %your_choice%==3 goto option3
if %your_choice%==2 goto option2
if %your_choice%==1 goto option1
echo Unrecognized option: %your_choice%
goto choice

echo 3
goto exit

echo 2
goto exit

echo 1
goto exit

set your_choice=