CMD [ /A | /U ] [ /Q ] [ /D ] [ /E:OFF] [ /F:OFF ] [ /V:OFF ] [[ /S ] [ /C | /K ] command string ]
ON ONON
/C or /R Carries out the command string then terminates
/K remains
/S Modifies the treatment of string after /C or /K
/Q Turns echo off
/D Disable execution of AutoRun commands from registry
/A | U Causes the output of internal commands to a pipe or file to be ANSI | Unicode
/T:fg Sets the foreground/background colors.
Value,Color, 0:Black, 1:Blue, 2:Green, 3:Aqua, 4:Red, 5:Purple, 6:Yellow, 7:White, 8:Gray, 9:Light blue, A:Light green, B:Light aqua, C:Light red, D:Light purple, E:Light yellow, F:Bright white
/E:ON|OFF
/X==/E:ON
/Y
==/E:OFF
command Extensions. Enabled by default.
F:ON|OFF file and directory name completion characters ( ^D ^F )
V:ON|OFF delayed environment variable expansion using ! as the delimiter. causes !var! to expand the variable var at execution time NOT at input time, which can be different as when used in a FOR loop.

Multiple commands separated by && must be enclosed in quotes.

If /C or /K is specified, then the remainder of the command line after the switch is processed as a command line, where the following logic is used to process quote (") characters:

quote characters on the command line are preserved if

Otherwise, if the first character is a quote character, it is stripped out and the last quote character in the command line is removed

If /D* was NOT specified on the command line, CMD starts by looksing for REG_SZ/REG_EXPAND_SZ registry variables, they are executed first.


Command Extensions are enabled unless disabled by /E:OFF .
To enable or disable extensions for all invocations of CMD : to 1 or 0.
The user specific setting takes precedence over the machine setting.
The command line switches take precedence over the registry settings.

The command extensions involve changes and/or additions to the following

DEL or ERASE COLOR, CD or CHDIR, MD or MKDIR, PROMPT, PUSHD, POPD, SET, SETLOCAL, ENDLOCAL, IF, FOR, CALL, SHIFT, GOTO, START (also includes changes to external command invocation), ASSOC, FTYPE

commandname /? to view the specifics.


Delayed environment variable expansion
* is NOT enabled by default.
To enable or disable it for a particular invocation of CMD use /V:ON or /V:OFF
To enable or disable it for all invocations of CMD modify REG_DWORD values in the registry: to 1 or 0. The user specific setting takes precedence over the machine setting. The command line switches take precedence over the registry settings.

If delayed environment variable expansion is enabled, then ! can be used to substitute the value of an environment variable at execution time.


File and Directory name completion is NOT enabled by default.
To enable or disable file name completion for a particular invocation of CMD use /F:ON or /F:OFF .
To enable or disable completion for all invocations of CMD modify the registry :

HKEY_LOCAL_MACHINE\Software\Microsoft\Command Processor\CompletionChar
or HKEY_LOCAL_MACHINE\...\PathCompletionChar

and/or

HKEY_CURRENT_USER\Software\Microsoft\Command Processor\CompletionChar
or
HKEY_CURRENT_USER\...\PathCompletionChar

with the hex value of a control character to use for a particular function (e.g. 4 is Ctrl-D and 06 is Ctrl-F The user precedence over machine, command line switches over registry .

If completion is enabled with the /F:ON , the two control characters used are Ctrl-D for directory name completion and Ctrl-F for file name completion.
To disable a completion character in the registry, use the value for space (0x20) .

Completion is invoked when you type either control characters. It takes the path string to the left of the cursor, appends a wild card character to it ( if none is already present ), builds up a list of paths that match then displays the first matching path. If no paths match, it beeps. repeated pressing of the same control character cycles through the list of matching paths. Use Shift with the control character to move through the list backwards. If you edit the line, or switch between file and directory name completion, and press the control character , the saved list of matching paths is discarded and a new one generated. File completion matches both file and directory names, while the directory completion only matches directory names. If file completion is used on any of the built in directory commands (CD, MD or RD) then directory completion is assumed.

The completion code deals with names that contain spaces or special characters by placing quotes around the matching path. If you back up, then invoke completion from within a line, the text to the right of the cursor at the point completion was invoked is discarded.

Microsoft details