Type: External (6.0 and later)
CHOICE [/C[:]keys] [/N][/S][/T[:]c,nn] [text]
Purpose: Used to provide a prompt so that a user can make a
a batch program is running (new with DOS Version 6).
This command is used only in batch programs. It is used to display a
the user. The specified prompt is displayed and the program pauses while
user makes a choice from a specified set of keys.
For more information on CHOICE and other batch commands, see Chapter 5,
text - Used to specify text to be displayed before the prompt. When
not been specified, CHOICE will display only the prompt. You must use
marks around the text if you include a switch character (/) as part of
/C[:]keys - Used to specify the keys that the user can select from when
prompt is displayed. When displayed, the list of key choices will be
by commas and enclosed in brackets with a question mark at the end. If
option is not used, the CHOICE command displays the default key choices
of Y and
N. The colon [:] is optional.
/N - When the /N option is used the prompt will not be displayed,
text before the prompt will be displayed and the specified keys will
/S - Using the /S option causes CHOICE to be case sensitive to the keys
entered by the user at the prompt.
/T[:]c,nn - The /T option can be used to limit the number of seconds
program will pause before it defaults to a specified key. The values for
c - Specifies the default key (character). The key must be one of
specified in the /C switch.
nn - Specifies the length of the pause in seconds (0 to 99).
If you were writing a batch program and wanted to use the CHOICE command
prompt the user to select from the keys Y, N, and C, you would enter the
The user would see the following prompt:
To make it more obvious to the user exactly what they are selecting, you
add some explanatory text to the prompt by entering,
choice /c:ync Yes, No, or Continue
The user would then see,
Yes, No, or Continue [Y,N,C]?
If you wanted to use the /T option to limit the amount of time a user has
make a choice at the prompt you might enter,
choice /c:ync /t:c,10
The user would still see the prompt [Y,N,C]? from which they could make
choice. If a selection was not made within 10 seconds the C option would
assumed and the batch program would continue.
Back to the