Developer(s) | Microsoft, Novell, Datalight, Jim Hall, ReactOS Contributors |
---|---|
Initial release | 1993, 30–31 years ago |
Operating system | DOS, Windows, ReactOS |
Platform | Cross-platform |
Type | Command |
License | MS-DOS, PC DOS, DR-DOS, Windows, PTS-DOS: Proprietary commercial software FreeDOS, ReactOS: GPL v2 |
Website | docs |
In computing, choice
is a command that allows for batch files to prompt the user to select one item from a set of single-character choices. [1] It is available in a number of operating system command-line shells.
The command was first introduced as an external command (with filenames CHOICE.COM or CHOICE.EXE) with MS-DOS 6.0. [2] It is included in Novell DOS 7 and IBM PC DOS 7.0, and is also available from the command-line shell of some versions of Microsoft Windows, but not under Windows 2000 and Windows XP. [3] It was first made available for Windows in the Windows XP Resource Kit. [4] It has been reintroduced in Windows Server 2003 and is present in later versions. [5]
Starting with Windows 2000, the SET
command has similar functionality using the /P
command-line argument. However this command requires an additional key stroke (hitting ENTER key), which is not required by choice
.
The choice
command has been ported to OS/2, Rexx and Perl. [6] It is also available in Datalight ROM-DOS, [7] FreeDOS, [8] PTS-DOS, [9] and ReactOS. [10] The FreeDOS version was developed by Jim Hall and is licensed under the GPL v2. [11]
The command returns the selected choice as an exit code which is set to the index of the key that the user selects from the list of choices. The first choice in the list returns a value of 1, the second a value of 2, and so forth. If a key is pressed that is not a valid choice, the command will sound a warning beep. If an error condition is detected, an exit code value of 255 will be returned. An exit code value of 0 will be returned if the user presses CTRL+BREAK or CTRL+C. Choice displays the default choices Y and N if used without parameters. [12]
CHOICE [/C[:]choices] [/N] [/S] [/T[:]c,nn] ["text"]
Arguments:
/C[:]choices
Specifies allowable keys. The default is "YN"./T[:]c,nn
This defaults choice to "c" after "nn" seconds.text
Specifies the prompt string to display. (Quotes are optional).Flags:
/N
Specifies not to display the choices and "?" at end of prompt string./S
Specifies that choice keys should be treated as case sensitive.CHOICE [/C [<Choice1><Choice2><…>]] [/N] [/CS] [/T <Timeout> /D <Choice>] [/M <"Text">]
Arguments:
/C[:]choices
Specifies allowable keys. The default is "YN". (Microsoft Windows restricts valid choice keys to a-z, A-Z, 0-9 and ASCII values of 128 to 254)/T[:]nn
This defaults choice to /D after "nn" seconds. Must be specified with default /D./D[:]c
This defaults choice to 'c'./M text
Specifies the prompt string to display.Flags:
/N
Specifies not to display the choices and "?" at end of prompt string./CS
Specifies that choice keys should be treated as case sensitive.The batch file below gives the user three choices. [13] The user is directed depending upon his input by evaluating the exit code using the IF ERRORLEVEL
command (which tests on "greater or equal"). The selected choice is then printed to the screen using the ECHO
command.
@ECHO off @CHOICE /C:123 IFERRORLEVEL3GOTOthreeIFERRORLEVEL2GOTOtwoIFERRORLEVEL1GOTOoneGOTOend:oneECHO You have pressed "1"! GOTOend:twoECHO You have pressed "2"! GOTOend:threeECHO You have pressed "3"! :end@PAUSE
CHOICE
command.select
in bash COMMAND.COM is the default command-line interpreter for MS-DOS, Windows 95, Windows 98 and Windows Me. In the case of DOS, it is the default user interface as well. It has an additional role as the usual first program run after boot. As a shell, COMMAND.COM has two distinct modes of operation: interactive mode and batch mode. Internal commands are commands stored directly inside the COMMAND.COM binary; thus, they are always available, but can only be executed directly from the command interpreter.
In computing, dir
(directory) is a command in various computer operating systems used for computer file and directory listing. It is one of the basic commands to help navigate the file system. The command is usually implemented as an internal command in the command-line interpreter (shell). On some systems, a more graphical representation of the directory structure can be displayed using the tree
command.
The mkdir
command in the Unix, DOS, DR FlexOS, IBM OS/2, Microsoft Windows, and ReactOS operating systems is used to make a new directory. It is also available in the EFI shell and in the PHP scripting language. In DOS, OS/2, Windows and ReactOS, the command is often abbreviated to md
.
In computing, at
is a command in Unix-like operating systems, Microsoft Windows, and ReactOS used to schedule commands to be executed once, at a particular time in the future.
An environment variable is a user-definable value that can affect the way running processes will behave on a computer. Environment variables are part of the environment in which a process runs. For example, a running process can query the value of the TEMP environment variable to discover a suitable location to store temporary files, or the HOME or USERPROFILE variable to find the directory structure owned by the user running the process.
Command Prompt, also known as cmd.exe or cmd, is the default command-line interpreter for the OS/2, eComStation, ArcaOS, Microsoft Windows, and ReactOS operating systems. On Windows CE .NET 4.2, Windows CE 5.0 and Windows Embedded CE 6.0 it is referred to as the Command Processor Shell. Its implementations differ between operating systems, but the behavior and basic set of commands are consistent. cmd.exe is the counterpart of COMMAND.COM in DOS and Windows 9x systems, and analogous to the Unix shells used on Unix-like systems. The initial version of cmd.exe for Windows NT was developed by Therese Stowell. Windows CE 2.11 was the first embedded Windows release to support a console and a Windows CE version of cmd.exe. The ReactOS implementation of cmd.exe is derived from FreeCOM, the FreeDOS command line interpreter.
In computing, XCOPY
is a command used on IBM PC DOS, MS-DOS, IBM OS/2, Microsoft Windows, FreeDOS, ReactOS, and related operating systems for copying multiple files or entire directory trees from one directory to another and for copying files across a network.
In computing, more
is a command to view the contents of a text file one screen at a time. It is available on Unix and Unix-like systems, DOS, Digital Research FlexOS, IBM/Toshiba 4690 OS, IBM OS/2, Microsoft Windows and ReactOS. Programs of this sort are called pagers. more
is a very basic pager, originally allowing only forward navigation through a file, though newer implementations do allow for limited backward movement.
In computing, SUBST
is a command on the DOS, IBM OS/2, Microsoft Windows and ReactOS operating systems used for substituting paths on physical and logical drives as virtual drives.
In computing, ATTRIB
is a command in Intel ISIS-II, DOS, IBM OS/2, Microsoft Windows and ReactOS that allows the user to change various characteristics, or "attributes" of a computer file or directory. The command is also available in the EFI shell.
A batch file is a script file in DOS, OS/2 and Microsoft Windows. It consists of a series of commands to be executed by the command-line interpreter, stored in a plain text file. A batch file may contain any command the interpreter accepts interactively and use constructs that enable conditional branching and looping within the batch file, such as IF
, FOR
, and GOTO
labels. The term "batch" is from batch processing, meaning "non-interactive execution", though a batch file might not process a batch of multiple data.
In computing, find
is a command in the command-line interpreters (shells) of a number of operating systems. It is used to search for a specific text string in a file or files. The command sends the specified lines to the standard output device.
In computing, label
is a command included with some operating systems. It is used to create, change, or delete a volume label on a logical drive, such as a hard disk partition or a floppy disk. Used without parameters, label
changes the current volume label or deletes the existing label.
In computing, title
is a command in various command-line interpreters (shells) on Microsoft Windows and ReactOS that changes the title for the graphical terminal emulator window. The command is also used within DFS and ADFS to change the title of the disc in the current drive.
In computing, net
is a command in IBM OS/2, Microsoft Windows, ReactOS and Greentea OS used to manage and configure the operating system from the command-line. It is also part of the IBM PC Network Program for DOS.
In computing, ftype
is a command-line utility on Microsoft Windows that is used to display or change the link between a file type and an executable program.
In computing, findstr is a command in the command-line interpreters (shells) of Microsoft Windows and ReactOS. It is used to search for a specific text string in computer files.
In computing, diskcomp
is a command used for comparing the complete contents of a floppy disk to another one.
In computing, replace
is a command that is used to replace one or more existing computer files or add new files to a target directory. Files with a hidden or system attribute set cannot be replaced using replace
. The command lists all files that are replaced.