Choice Command In Windows Server 2008

This article shows how to use Choice command in Windows server 2008 and syntax related with it.
  • 1751


Choice command applies to all versions of Windows except Windows XP. Choice command is used to display a prompt to the user. Choice command allows users to select one item from a list of choices and returns the index of  that choice to the program. The specified prompt is displayed and the program pauses while the user makes a choice from a selection list.


choice [/c [<Choice1><Choice2><..>]] [/n] [/s] [/t <Timeout> /d <Choice>] [/m <"Text">]

In the above syntax

Parameters of Choice command Description
/c <Choice1><Choice2><…> Used to specify the list of choices to be created. If the /C option is not used, the CHOICE command displays the default key choices of Y and N.
/n Does not display list of choices. The text before the prompt will be displayed and the choices are still enabled.
/s specifies that choice keys are case sensitive.
/t <Timeout> Specifies the number of seconds to pause before it defaults to a specified key. Acceptable values are from 0 to 9999. If /t is set to 0, there will no pause before returning the default choice.
/d <Choice> Specifies the default choice to use after waiting the number of seconds assigns by /t. Lists of choices specified by  /c must contain the default choice.  
/m <"Text"> The message before the prompt is displayed.


If you want to prompt the user to select from the following keys- Y, N, and C, type the following line:

choice /c YNC

The user would see the following prompt, when choice command is executed:


Ask Your Question

Got a programming related question? You may want to post your question here

Programming Answers here


More Articles

© 2020 DotNetHeaven. All rights reserved.