MS-DOS and Windows command line option command
Updated:
12/30/2021
by
Reckoner Hope
The
selection
command allows users to keep batch files and scripts from running while they make a set of choices.
Microsoft Windows 2000 and Windows XP users who have batch files that utilize the choice command should modify the batch file to use the MS-DOS set command.
Availability
Pick is an external command and is available for the following Microsoft operating systems. Early versions of MS-DOS used choice.com as the external file. All versions of Windows utilize choicee.exe every bit the external file.
- MS-DOS 6.0+
- Windows 95
- Windows 98
- Windows Vista
- Windows 7
- Windows 8
- Windows 10
- Windows 11
Choice syntax
- Windows Vista and later syntax
- Windows XP and before syntax
Windows Vista and afterwards syntax
Pick [/C choices] [/N] [/CS] [/T timeout /D choice] [/1000 text]
/C choices | Specifies the list of choices to be created. Default list is “YN”. |
/N | Hides the listing of choices in the prompt. The message before the prompt is displayed and the choices are still enabled. |
/CS | Enables instance-sensitive choices to be selected. Past default, the utility is instance-insensitive. |
/T timeout | The number of seconds to break before a default choice is made. Acceptable values are from 0 to 9999. If 0 is specified, there will be no pause and the default choice is selected. |
/D choice | Specifies the default selection after nnnn seconds. Character must exist in the set of choices specified past /C option and must also specify nnnn with /T. |
/Grand text | Specifies the bulletin to show before the prompt. If non specified, the utility displays only a prompt. |
NOTE:
The ERRORLEVEL environs variable is set up to the alphabetize of the key that was selected from the set of choices. The first selection listed returns a value of 1, the second a value of 2, etc. If the user presses a key that is not a valid choice, the tool sounds a warning beep. If tool detects an error condition, information technology returns an ERRORLEVEL value of 255. If the user presses
Ctrl+Interruption
or
Ctrl+C, the tool returns an ERRORLEVEL value of 0. When yous employ ERRORLEVEL parameters in a batch plan, list them in decreasing society.
Examples:
CHOICE /? Option /C YNC /M "Printing Y for Yes, Due north for No or C for Cancel." Choice /T 10 /C ync /CS /D y CHOICE /C ab /One thousand "Select a for selection one and b for option 2." Choice /C ab /Northward /M "Select a for option 1 and b for choice 2."
Windows XP and earlier syntax
pick [/C[:]choices] [/Northward] [/S] [/T[:]c,nn] [text]
Options
/C[:]choices | Specifies allowable keys. Default is Y/Due north. |
/North | Practise not display choices and “?” at end of prompt string. |
/S | Treat choice keys as case-sensitive. |
/T[:]c,nn | Default choice to c after nn seconds. |
text | Prompt string to brandish. |
Choice examples
See the following page for examples on using the selection and set in a batch file.
Source: https://www.computerhope.com/choicehl.htm