Windows 7 / Getting Started

CMD Options

CMD has several command-line options. Although you don't often need to use these options, you might want to be familiar with them. To start the command shell with alternative settings, you can type start cmd with additional parameters or run cmd from within a shortcut, batch file, and so on.

The syntax of the CMD command itself is as follows:

cmd [/a | /u] [/q] [/d] [/t:fg] [/e:on|off] [/f:on|off] [/v:on|off] [[/s] [/c | /k] [command]

You can give CMD a specific command line to execute, or you can start it without a command. In the latter case, it repeatedly prompts for commands.

The options are described here.The features noted with an asterisk are discussed in the following sections:

OptionsDescriptions
/aCauses standard output to use ANSI encoding.
/uCauses standard output to use Unicode encoding.
/qTurns the batch file echo default to off.
/dDisables execution of AutoRun commands defined in the Registry. Use this if a rogue program (or you) sets up a bad AutoRun entry.
/t:bfSets the background (window) and foreground (text) colors for the window. For example, /t:80 specifies black text on a gray background. The color values are listed in Table below.
/eEnables or disables the command extensions.
/fEnables or disables the file and directory name completion feature.
/vEnables delayed environment variable expansion of !varname!
/sModifies the treatment of quotation marks on the command line
/cExecutes the command(s) in command and then quits.
/kExecutes the command(s) in command and then reads further commands from the standard input until end of file or until the exit command is received.

If used, the /c or /k option must appear immediately before the command string. Anything after /c or /k is treated as part of the command to be run, rather than an argument to CMD.

Several nonstandard command-line arguments are also recognized to maintain compatibility with batch files written for Windows NT 4.0:

ArgumentsDescription
/xSame as /e:on. Enables command extensions.
/ySame as /e:off. Disables command extensions.
/rSame as /c. Executes command and quits.

The color codes used with /t are listed in Table below.

Color Codes Used with /t
ValueColor
0Black
1Blue
2Green
3Aqua
4Red
5Purple
6Yellow
7White
8Gray
9Light Blue
ALight Green
BLight Aqua
CLight Red
DLight Purple
ELight Yellow
FBright White
[Previous] [Contents] [Next]