Choice

2008 Oct 18


Name CHOICE
Ver 2000
Suspends batch-file processing and prompts user to make a choice before
processing resumes. You can specify which keystrokes are accepted and what
default chocies are made if no keys are pressed.
Syntax CHOICE /C:keys /N /S /T:choice,seconds prompt
Optional
Parameters
and Switches
/C:keys Specifies which keys are displayed in the prompt.
The colon, :, is optional. If /C not specified default is /C:YN.
/N Suppress key list and question mark that DOS adds
to prompt (see note 1).
/S Enables case sensititivity, i.e. lower and upper case key responses
are different. Default is upper and lower case keys are identical.
/T:choice,seconds Sepcifies a default key and the number of seconds to wait for user
to press a key before the default is used. The colon, :, is optional.
choice must be one of the keys specified by /C:keys. The range
of seconds is 0 .. 99.
prompt Specifies prompt string that is displayed to user, followed by a
bracketed list of allowable keys followed by a question mark.
Quotation can be used around text, but is only needed if the prompt
contains the switch character, /, redirection characters or
trailing spaces. If prompt is not specified then DOS does
not display any prompt.
Exit Codes
ERRORLEVEL
Value
MeaningM/th>
0 Choice terminated by user (Ctrl+Break, Ctrl+C)
1 User picked first key in /C:keys
2 User picked second key in /C:keys
4 up ... etc. ...
255 Terminated by error (e.g. illegal syntax)
Notes
1) This command display's the user's prompt, followed by
   [keys]? (where keys are comma separated), e.g. [Y,N]?.
2) If the user presses a key that is not in the kets list
   the beeps and waits for a specified key.
See also
IF

2005-2008