Windows 命令Windows commands

所有受支持的 Windows (server 和客户端) 中内置了一组 Win32 控制台命令。All supported versions of Windows (server and client) have a set of Win32 console commands built in.

此文档集介绍了可用于通过脚本或脚本工具自动执行任务的 Windows 命令。This set of documentation describes the Windows Commands you can use to automate tasks by using scripts or scripting tools.


本主题中包含的信息适用于:The information that is contained in this topic applies to:

  • Windows Server 2019Windows Server 2019
  • Windows Server(半年频道)Windows Server (Semi-Annual Channel)
  • Windows Server 2016Windows Server 2016
  • Windows Server 2012 R2Windows Server 2012 R2
  • Windows Server 2012Windows Server 2012
  • Windows Server 2008 R2Windows Server 2008 R2
  • Windows 2008 ServerWindows Server 2008
  • Windows 10Windows 10
  • Windows 8.1Windows 8.1

命令外壳概述Command shell overview

命令行界面是内置于 Windows 中的第一个 shell,用批处理 ( bat) 文件自动完成日常任务,如用户帐户管理或夜间备份。The Command shell was the first shell built into Windows to automate routine tasks, like user account management or nightly backups, with batch (.bat) files. 借助 Windows 脚本宿主,你可以在命令行界面中运行更复杂的脚本。With Windows Script Host you could run more sophisticated scripts in the Command shell. 有关详细信息,请参阅cscriptwscript.echoFor more information, see cscript or wscript. 使用脚本可以更有效地执行操作,而不是使用用户界面。You can perform operations more efficiently by using scripts than you can by using the user interface. 脚本接受命令行中可用的所有命令。Scripts accept all Commands that are available at the command line.

Windows 有两个命令 shell:命令 shell 和PowerShellWindows has two command shells: The Command shell and PowerShell. 每个 shell 是一种软件程序,它提供你与操作系统或应用程序之间的直接通信,同时提供用于自动执行 IT 操作的环境。Each shell is a software program that provides direct communication between you and the operating system or application, providing an environment to automate IT operations.

PowerShell 旨在扩展命令行界面的功能,以运行称为 cmdlet 的 PowerShell 命令。PowerShell was designed to extend the capabilities of the Command shell to run PowerShell commands called cmdlets. Cmdlet 类似于 Windows 命令,但提供更可扩展的脚本语言。Cmdlets are similar to Windows Commands but provide a more extensible scripting language. 可以在 Powershell 中运行 Windows 命令和 PowerShell cmdlet,但命令 shell 只能运行 Windows 命令,而不能运行 PowerShell cmdlet。You can run Windows Commands and PowerShell cmdlets in Powershell, but the Command shell can only run Windows Commands and not PowerShell cmdlets.

对于最新的 Windows automation 最新功能,建议使用 PowerShell,而不是 Windows 命令或 windows 脚本宿主来实现 Windows automation。For the most robust, up-to-date Windows automation, we recommend using PowerShell instead of Windows Commands or Windows Script Host for Windows automation.


你还可以下载和安装 powershell Core,即 powershell 的开源版本。You can also download and install PowerShell Core, the open source version of PowerShell.


不正确地编辑注册表可能会对系统造成严重损坏。Incorrectly editing the registry may severely damage your system. 在对注册表进行以下更改之前,应备份计算机上任何有价值的数据。Before making the following changes to the registry, you should back up any valued data on the computer.


若要在计算机或用户登录会话上的命令行界面中启用或禁用文件和目录名完成,请运行regedit.exe ,并设置以下reg_DWOrd 值To enable or disable file and directory name completion in the Command shell on a computer or user logon session, run regedit.exe and set the following reg_DWOrd value:

HKEY_LOCAL_MACHINE \Software\Microsoft\Command Processor\completionChar\ reg_DWOrdHKEY_LOCAL_MACHINE\Software\Microsoft\Command Processor\completionChar\reg_DWOrd

若要设置reg_DWOrd值,请将控制字符的十六进制值用于特定函数 (例如, 0 9为 Tab, 0 08为 Backspace) 。To set the reg_DWOrd value, 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.

命令行参考 a-zCommand-line reference A-Z

若要查找有关特定命令的信息,请在下面的 A-z 菜单中,单击命令开头的字母,然后单击命令名称。To find information about a specific command, in the following A-Z menu, click the letter that the command starts with, and then click the command name.

一个 | B | C | D | E | F | G | H | I | J | K | L | M | N | O | P | Q | R | S | T | U | V | W | X |Y |ZA | B | C | D | E | F | G | H | I | J | K | L | M | N | O | P | Q | R | S | T | U | V | W | X | Y | Z