choice
Prompts the user to select one item from a list of single-character choices in a batch program, and then returns the index of the selected choice. Windows commands reference
On Windows, DOS 1 Sigma rule name it File choice.exe
Windows
Prompts the user to select one item from a list of single-character choices in a batch program, and then returns the index of the selected choice. If used without parameters, choice displays the default choices Y and N. - The ERRORLEVEL environment variable is set to the index of the key that the user selects from the list of choices. The first choice in the list returns a value of 1, the second a value of 2, and so on. If the user presses a key that is not a valid choice, choice sounds a warning beep. - If choice detects an error condition, it returns an ERRORLEVEL value of 255. If the user presses CTRL+BREAK or CTRL+C, choice returns an ERRORLEVEL value of 0. NOTE: When you use ERRORLEVEL values in a batch program, you must list them in decreasing order.
choice [/c [<choice1><choice2><…>]] [/n] [/cs] [/t <timeout> /d <choice>] [/m <text>]
To present the choices Y, N, and C, type the following line in a batch file
choice /c yncIdentify/cSpecifies the list of choices to be created. Windows commands referenceThe following prompt appears when the batch file runs the choice command
[Y,N,C]?To hide the choices Y, N, and C, but display the text Yes, No, or Continue, type the following line in a batch file
choice /c ync /n /m "Yes, No, or Continue?"Identify/cSpecifies the list of choices to be created. Windows commands reference/nHides the list of choices, although the choices are still enabled and the message text (if specified by /m) is still displayed. Windows commands reference/mSpecifies a message to display before the list of choices. Windows commands referenceTo show both the text and the options used in the previous examples, type the following line in a batch file
choice /c ync /m "Yes, No, or Continue"Identify/cSpecifies the list of choices to be created. Windows commands reference/mSpecifies a message to display before the list of choices. Windows commands referenceTo set a time limit of five seconds and specify N as the default value, type the following line in a batch file
choice /c ync /t 5 /d nIdentify/cSpecifies the list of choices to be created. Windows commands reference/tSpecifies the number of seconds to pause before using the default choice specified by /d. Windows commands reference/dSpecifies the default choice to use after waiting the number of seconds specified by /t. Windows commands reference/c <choice1><choice2><…>Specifies the list of choices to be created. Valid choices include a-z, A-Z, 0-9, and extended ASCII characters (128-254). The default list is YN, which is displayed as [Y,N]?./nHides the list of choices, although the choices are still enabled and the message text (if specified by /m) is still displayed./csSpecifies that the choices are case-sensitive. By default, the choices are not case-sensitive./t <timeout>Specifies the number of seconds to pause before using the default choice specified by /d. Acceptable values are from 0 to 9999. If /t is set to 0, choice does not pause before returning the default choice./d <choice>Specifies the default choice to use after waiting the number of seconds specified by /t. The default choice must be in the list of choices specified by /c./m <text>Specifies a message to display before the list of choices. If /m is not specified, only the choice prompt is displayed./?Displays help at the command prompt.Windows
Prompt user to select a choice and return the selected choice index.
Prompt the current user to select a Y or N choice
choiceIdentifyPrompt the current user to select a choice from a specific set
choice /c ABIdentify/cSpecifies the list of choices to be created. Windows commands referencePrompt the current user to select a choice with a specific message
choice /m "message"Identify/mSpecifies a message to display before the list of choices. Windows commands referencePrompt the current user to select a case-sensitive choice from a specific set
choice /cs /c AbIdentify/csSpecifies that the choices are case-sensitive. Windows commands reference/cSpecifies the list of choices to be created. Windows commands referencePrompt the current user to select a choice and prefer the default choice in a specific time
choice /t 5 /d default_choiceIdentify/tSpecifies the number of seconds to pause before using the default choice specified by /d. Windows commands reference/dSpecifies the default choice to use after waiting the number of seconds specified by /t. Windows commands referenceDOS
Wait for keypress and set ERRORLEVEL in batch scripts.
Prompt for yes/no
CHOICE "prompt"Identify