Command: choice, _choice

  CHOICE / _CHOICE suspends processing and waits for the user to press a
  valid key from a given list of choices. Choice gives out an ERRORLEVEL
  which can be used for further work.

Syntax:

  CHOICE [ /B ] [ /C[:]choices ] [ /N ] [ /S ] [ /T[:]c,nn ] [ text ] [/?]
  _CHOICE [ /B ] [ /C[:]choices ] [ /N ] [ /S ] [ /T[:]c,nn ] [ text ] [/?]

[Main menu] [top] (Syntax) [Options] [Comments] [Examples] [See also] [File]

Options:

  /B         Sound an alert (beep) at prompt
  /C[:]      choices  -  Specifies allowable keys. Default is: yn (if
             /C was not used), you may also be 0 - 9 or A - Z.
  /N         Do not display the choices and ? at end of prompt
  /S         Treat choices as case-sensitive
  /T[:]c,nn  Automatically choose key c after nn seconds
             c must be one of the keys specified with /C; nn may be a
             value between 0 and 99. 
  text       The text to display as a prompt (default=none)
  /?         Shows the help

[Main menu] [top] [Syntax] (Options) [Comments] [Examples] [See also] [File]

Comments:

  CHOICE shows the messages according to the file %NLSPATH%\CHOICE.%LANG%,
  where LANG is SET in the environment variable in autoexec.bat and NLSPATH
  is the path to the national language files.
  _CHOICE uses english texts only.
  CHOICE is not a command internal to command.com and needs a 
  choice file in order to work.
  CHOICE supports NLS (national language support).
  CHOICE has the following EXITCODES (ERRORLEVEL):
    0    if aborted
    ...  ERRORLEVEL is set to offset of key user presses in choices.
    255  any error

[Main menu] [top] [Syntax] [Options] (Comments) [Examples] [See also] [File]

Examples:

  in a batch file
  
   @ECHO 1 = Do this
   @ECHO 2 = Do that
   @ECHO 3 = Do another thing
   @ECHO 4 = Do nothing
   @choice /B /C:1234 /N /S What do you want to do?
   if errorlevel 4 goto DONOTHING
   if errorlevel 3 goto DOANOTHER
   if errorlevel 2 goto DOTHAT
   if errorlevel 1 goto DOTHIS

   :DOTHIS
   your DOTHIS-commands
   goto EXIT
   
   :DOTHAT
   your DOTHAT-commands
   goto EXIT
  
   :DOANOTHER
   your DOANOTHER-commands
   goto EXIT

   :DONOTHING
   your DONOTHING-commands
   goto EXIT

   :EXIT

[Main menu] [top] [Syntax] [Options] [Comments] (Examples) [See also] [File]

See also:

  autoexec.bat
  batch files
  if
  goto
  pause
  set

[Main menu] [top] [Syntax] [Options] [Comments] [Examples] (See also) [File]

File:

  Please read this command's lsm file also.
  You will find the updated version (internet) here and
  the version described in this manual page here.
  The lsm file contains information about the name of the programmer,
  the download site, and some other command related information.

[Main menu] [top] [Syntax] [Options] [Comments] [Examples] [See also] (File)


  Copyright © 1994-2003 Jim Hall, updated 2008 by W. Spiegl.

  This file is derived from the FreeDOS Spec Command HOWTO.
  See the file H2Cpying for copying conditions.