Starts a new instance of the command interpreter, Cmd.exe. If used without parameters, cmd displays the version and copyright information of the operating system.

Syntax

cmd [/c|/k] [/s] [/q] [/d] [/a|/u] [/t:{<B><F>|<F>}] [/e:{on|off}] [/f:{on|off}] [/v:{on|off}] [<String>]

Parameters

Parameter Description

/c

Carries out the command specified by String and then stops.

/k

Carries out the command specified by String and continues.

/s

Modifies the treatment of String after /c or /k.

/q

Turns the echo off.

/d

Disables execution of AutoRun commands.

/a

Formats internal command output to a pipe or a file as American National Standards Institute (ANSI).

/u

Formats internal command output to a pipe or a file as Unicode.

/t:{<B><F>|<F>}

Sets the background (B) and foreground (F) colors.

/e:on

Enables command extensions.

/e:off

Disables commands extensions.

/f:on

Enables file and directory name completion.

/f:off

Disables file and directory name completion.

/v:on

Enables delayed environment variable expansion.

/v:off

Disables delayed environment variable expansion.

<String>

Specifies the command you want to carry out.

/?

Displays help at the command prompt.

The following table lists valid hexadecimal digits that you can use as the values for <B> and <F>:

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

Remarks

  • Using multiple commands

    To use multiple commands for <String>, separate them by the command separator && and enclose them in quotation marks. For example:

    "<Command>&&<Command>&&<Command>"
    
  • Processing quotation marks

    If you specify /c or /k, cmd processes the remainder of String, and quotation marks are preserved only if all of the following conditions are met:

    • You do not use /s.

    • You use exactly one set of quotation marks.

    • You do not use any special characters within the quotation marks (for example: & < > ( ) @ ^ | ).

    • You use one or more white-space characters within the quotation marks.

    • The String within quotation marks is the name of an executable file.

    If the previous conditions are not met, String is processed by examining the first character to verify whether it is an opening quotation mark. If the first character is an opening quotation mark, it is stripped along with the closing quotation mark. Any text following the closing quotation marks is preserved.

  • Executing registry subkeys

    If you do not specify /d in String, Cmd.exe looks for the following registry subkeys:

    HKEY_LOCAL_MACHINE\Software\Microsoft\Command Processor\AutoRun\REG_SZ

    HKEY_CURRENT_USER\Software\Microsoft\Command Processor\AutoRun\REG_EXPAND_SZ

    If one or both registry subkeys are present, they are executed before all other variables.

Caution

Incorrectly editing the registry may severely damage your system. Before making changes to the registry, you should back up any valued data on the computer.

  • Enabling and disabling command extensions

    Command extensions are enabled by default in Windows XP. You can disable them for a particular process by using /e:off. You can enable or disable extensions for all cmd command-line options on a computer or user session by setting the following REG_DWORD values:

    HKEY_LOCAL_MACHINE\Software\Microsoft\Command Processor\EnableExtensions\REG_DWORD

    HKEY_CURRENT_USER\Software\Microsoft\Command Processor\EnableExtensions\REG_DWORD

    Set the REG_DWORD value to either 0×1 (enabled) or 0×0 (disabled) in the registry by using Regedit.exe. User-specified settings take precedence over computer settings, and command-line options take precedence over registry settings.

    Caution   Incorrectly editing the registry may severely damage your system. Before making changes to the registry, you should back up any valued data on the computer.

    When you enable command extensions, the following commands are affected:

    • assoc

    • call

    • chdir (cd)

    • color

    • del (erase)

    • endlocal

    • for

    • ftype

    • goto

    • if

    • mkdir (md)

    • popd

    • prompt

    • pushd

    • set

    • setlocal

    • shift

    • start (also includes changes to external command processes)

  • Enabling delayed environment variable expansion

    If you enable delayed environment variable expansion, you can use the exclamation point character to substitute the value of an environment variable at run time.

  • Enabling file and directory name completion

    File and directory name completion is not enabled by default. You can enable or disable file name completion for a particular process of the cmd command with /f:{on|off}. You can enable or disable file and directory name completion for all processes of the cmd command on a computer or for a user logon session by setting the following REG_DWORD values:

    HKEY_LOCAL_MACHINE\Software\Microsoft\Command Processor\CompletionChar\REG_DWORD

    HKEY_LOCAL_MACHINE\Software\Microsoft\Command Processor\PathCompletionChar\REG_DWORD

    HKEY_CURRENT_USER\Software\Microsoft\Command Processor\CompletionChar\REG_DWORD

    HKEY_CURRENT_USER\Software\Microsoft\Command Processor\PathCompletionChar\REG_DWORD

    To set the REG_DWORD value, run Regedit.exe and use the hexadecimal value of a control character for a particular function (for example, 0×9 is TAB and 0×08 is BACKSPACE). User-specified settings take precedence over computer settings, and command-line options take precedence over registry settings.

Caution

Incorrectly editing the registry may severely damage your system. Before making changes to the registry, you should back up any valued data on the computer.

If you enable file and directory name completion by using /f:on, use CTRL+D for directory name completion and CTRL+F for file name completion. To disable a particular completion character in the registry, use the value for white space [0×20] because it is not a valid control character.

If you process file and directory name completion from within String, any part of the Path to the right of the cursor is discarded (at the point in String where the completion was processed).

Additional references