System command

cmd command

Start a new command interpreter with execution, environment and window options.

Availability: Microsoft Learn command reference spanning Windows client and Windows Server releases; some entries are legacy, role-specific, optional-feature or interactive subcommands.中文

Documented syntax

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

The linked Microsoft Learn article is the upstream authority. Availability may depend on Windows release, role, optional feature or interactive tool context.

Examples

Example usage for cmd.

cmd /c echo Build complete

Parameters, options and clauses

Option / clauseDescription
/c <string>Run the command and then exit the command interpreter.
/k <string>Run the command and keep the interpreter open.
/dDisable AutoRun commands from the registry.
/qTurn command echo off.
/sApply quote-processing rules with /c or /k.
/a /uChoose ANSI or Unicode output for internal commands.
/e:on|off /v:on|off /f:on|offControl command extensions, delayed expansion and filename completion.
/t:{<b><f>Microsoft documents this switch; use the linked reference for accepted values, effects and version limits.
/?Display command help or the supported command-line usage.
ValueMicrosoft documents this argument or subcommand; check the linked reference for its required format and context.
0Microsoft documents this argument or subcommand; check the linked reference for its required format and context.
1Microsoft documents this argument or subcommand; check the linked reference for its required format and context.
2Microsoft documents this argument or subcommand; check the linked reference for its required format and context.
3Microsoft documents this argument or subcommand; check the linked reference for its required format and context.
4Microsoft documents this argument or subcommand; check the linked reference for its required format and context.
5Microsoft documents this argument or subcommand; check the linked reference for its required format and context.
6Microsoft documents this argument or subcommand; check the linked reference for its required format and context.
7Microsoft documents this argument or subcommand; check the linked reference for its required format and context.
8Microsoft documents this argument or subcommand; check the linked reference for its required format and context.
9Microsoft documents this argument or subcommand; check the linked reference for its required format and context.
bMicrosoft documents this argument or subcommand; check the linked reference for its required format and context.
<f>Microsoft documents this argument or subcommand; check the linked reference for its required format and context.
Safety note

Review a command and its target before running it. Commands that alter files, services, accounts, disks, permissions or databases may be difficult to reverse. Test in a safe environment and keep backups.

Official reference ↗Back to directory