CHOICE.exe – Windows CMD Command
Notice: A non well formed numeric value encountered in /home/future4tech/public_html/wp-content/plugins/crayon-syntax-highlighter/crayon_formatter.class.php on line 118
Notice: A non well formed numeric value encountered in /home/future4tech/public_html/wp-content/plugins/crayon-syntax-highlighter/crayon_formatter.class.php on line 119
Notice: A non well formed numeric value encountered in /home/future4tech/public_html/wp-content/plugins/crayon-syntax-highlighter/crayon_formatter.class.php on line 118
Notice: A non well formed numeric value encountered in /home/future4tech/public_html/wp-content/plugins/crayon-syntax-highlighter/crayon_formatter.class.php on line 119
Accept user input to a batch file. Choice allows single key-presses to be captured from the keyboard.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 |
CHOICE [/c [choiceKeys]] [/N] [/CS] [/t Timeout /d Choice] [/m Text] key /C[:]choiceKeys : One or more keys the user can press. Default is YN. /N : Do not display choiceKeys at the end of the prompt string. /CS : Make the choiceKeys Case Sensitive. /T Timeout : Timeout in Timeout seconds If Timeout is 0 there will be no pause and the default will be selected. /d choice : Default choice made on Timeout. /m text : Message string to describe the choices available. |
ERRORLEVEL will return the numerical offset of choice keys.
Choice.exe is a standard command in Windows 2003 and greater, it was first made available in the Windows XP resource kit.
CHOICE can be used to set a specific %errorlevel%
for example to set the %errorlevel% to 6 :
ECHO 6| CHOICE /C 123456 /N >NUL
1 2 3 4 5 |
Examples: CHOICE /C CH /M Select [C] CD or [H] Hard drive IF %ERRORLEVEL% EQU 2 goto sub_hard_drive IF %ERRORLEVEL% EQU 1 goto sub_cd |