Windows CMD 命令大全:常用命令与 2026 更新
Some links on this page are affiliate links: if you buy through them we may earn a commission, at no extra cost to you.
Windows CMD 命令大全不能用一张固定清单覆盖所有系统:CMD 是 Windows 的 cmd.exe 命令解释器。截至 2026 年 8 月 12 日,最可靠的更新方法仍是使用当前系统的 命令 /? 和微软官方命令文档核对参数。
本文按文件目录、文本和批处理、系统维护、网络诊断、程序启动与权限管理分类说明常用命令,并解释 Windows 11 26H1、25H2、24H2 更新背景。示例用于说明语法,不代表本文对每条命令进行过实际运行测试。
#
Preview
Product
Price
1
Perixx PERIPRO-401 PS2 to USB Adapter for Keyboard and Mouse - Built-in USB Controller - Black
$8.99
Buy on Amazon
2
UCEC PS/2 to USB Adapter Converter for PS2 Keyboard Mouse Accessories | USB to Dual PS/2 Cables...
$8.99
Buy on Amazon
3
XIAOQENAN USB To Keyboards Adapter Keyboards To USB Adapter For And Keyboard Compatibility With...
$5.99
Buy on Amazon
4
YARCHONN USB to PS/2 Converter Adapter Keyboard Cable 18cm | PS2 Female Keyboard Mouse Interface to...
$8.99
Buy on Amazon
5
USB Hub 4 Port, USB Splitter 1 in 4 Out, USB Extender Hub for Laptop PC | Multiport USB Adapter,...
$5.99
Buy on Amazon
As an Amazon Associate I earn from qualifying purchases.
Key takeaways
cmd.exe 是 Windows 的命令解释器;cmd /c 执行命令后退出,cmd /k 执行命令后保留窗口。
命令 /? 是确认当前 Windows 版本支持哪些参数、参数如何使用的首要方法,第三方“完整命令表”不能替代系统帮助。
dir、cd、copy、robocopy、del 和 findstr 覆盖了最常见的文件、目录和文本操作。
sfc、DISM、chkdsk、ipconfig、ping、nslookup 和 netstat 分别用于系统维护或网络排查,但修复、删除、强制终止和关机命令都可能造成数据或连接中断。
截至 2026 年 8 月 12 日,Windows 11 release information 页面列出的通用可用版本包括 26H1、25H2 和 24H2;版本更新没有让传统 CMD 命令整体消失,脚本仍应按当前系统的帮助和返回状态验证。
什么是 Windows CMD 命令
Windows CMD 命令大全实际上不是一张永远固定的清单:CMD 通常指 Windows 的 cmd.exe 命令解释器,CMD 能执行内置命令,也能启动独立的 .exe、.com、.bat 和 .cmd 程序。微软的cmd 官方文档是确认启动参数和行为的首要参考。
直接执行 cmd 会启动一个新的命令解释器实例。cmd /c "命令" 会运行命令并退出,cmd /k "命令" 会运行命令但保留命令提示符窗口。
Popular on Amazon
Perixx PERIPRO-401 PS2 to USB Adapter for Keyboard and Mouse - Built-in USB Controller - Black
PS/2-to-USB ADAPTER: Adapter for those who like to continue using their PS/2 devices. Connect mouse and keyboard to your computer by using only one USB portSUITABLE FOR PS/2 DEVICES: Two PS2 female ports, purple for keyboard and green for mouse, and one USB male port.BUILT-IN USB-IC: You can use PERIPRO-401 to connect your keyboard and mouse with PS2 interface to USB 2. 0 port at PC or laptop. It also supports PS/2 Port of KVM Switch.UNIVERSAL PURPOSES: Fits with industrial and professional needsPACKAGE INCLUDES: Perixx PERIPRO-401 adapter, manual; 12-month limited
$8.99
Buy on Amazon
启动方式
作用
适用场景
cmd
启动新的 CMD 实例
进入独立的命令环境
cmd /c "命令"
执行命令后退出
由其他程序或脚本临时调用
cmd /k "命令"
执行命令后保留窗口
执行后查看输出或继续输入命令
cmd /d
禁用 AutoRun 命令
排查启动脚本或环境污染
cmd /e:on、cmd /e:off
开启或关闭命令扩展
兼容特定批处理脚本
cmd /v:on
启用延迟环境变量扩展
在循环或括号块中读取动态变量
cmd /f:on
启用文件名和目录名补全
减少交互式输入路径的工作量
CMD 更适合传统批处理、兼容旧脚本、运行安装程序和快速执行简单的 Windows 命令。微软将 PowerShell 定义为命令行 shell、脚本语言和自动化框架;复杂系统管理和自动化通常应进一步评估 PowerShell,而不是持续堆叠越来越长的 CMD 批处理逻辑。
微软对命令 shell 的说明和PowerShell 官方概览可以帮助区分 CMD 与 PowerShell 的定位。
CMD 的基本语法是什么
命令 /? 是 Windows CMD 中最重要的自检方法。几乎所有微软官方 CMD 命令都支持帮助参数,例如:
ipconfig /?
dir /?
sfc /?
命令参数可能因 Windows 版本、Windows Server 版本、恢复环境、系统语言或当前权限而不同。微软提供的Windows Commands Reference适合作为集中参考,但执行前仍应在目标电脑上运行对应的 命令 /?。
路径包含空格时为什么必须加引号
CMD 会把空格当作参数分隔符,因此路径或文件名含空格时,应使用双引号。cd /d 还可以在切换目录的同时切换驱动器:
cd /d "C:Program Files"
del "C:Temp Filesold.txt"
cd C:Users
cd /d D:Projects
cd ..
cd
仅执行 cd D:Projects 时,在某些情况下不会同时把当前驱动器切换到 D 盘;需要跨驱动器改变工作目录时,优先使用 cd /d。
如何在 CMD 中连接命令、管道和保存输出
CMD 的命令连接和重定向由命令解释器处理。CMD 的文本管道与 PowerShell 的对象管道不是同一种机制。
语法
行为
示例
&
无论前一个命令成功或失败,都执行下一个命令
dir & echo Done
&&
前一个命令成功时才执行下一个命令
mkdir C:Work && echo Created
||
前一个命令失败时才执行下一个命令
dir C:Missing || echo Failed
|
把前一个命令的文本输出传给下一个命令
tasklist | findstr notepad
>
覆盖写入文件
ipconfig /all > network.txt
>>
追加写入文件
systeminfo >> audit.txt
使用 > 保存诊断信息时,已有同名文件会被覆盖;需要保留历史输出时,应改用 >>。
文件和目录 CMD 命令有哪些
文件管理命令适合日常浏览、创建、复制、移动、改名和删除。删除操作不可依赖 CMD 撤销,因此涉及通配符或递归参数时,应先用只读命令确认目标。
Also popular on Amazon
UCEC PS/2 to USB Adapter Converter for PS2 Keyboard Mouse Accessories | USB to Dual PS/2 Cables Accessories (Black)
PS/2 to USB ADAPTER: Premium computers accessories - PS2 to USB adapter - compatible for PS2 Keyboard/ PS2 Mouse/ Windows/ Mac/ Linux/ Bar Code ScannerCABLES INTERCONNECTS FUNCTIONAL: USB to ps2 adapter with two PS2 female ports, PS2 mouse and keyboard through USB port on any computerUSAGE: PS2 adapter to usb is compliant with the Standard Specification of USB 1.0 and 1.1. Purple port for keyboard and green one for mouseCONVENIENCE: PS/2 to USB converter converts two PS/2 devices (Keyboard and Mouse) to the USB InterfaceCOMPATIBILITY: PS2 USB adapter keyboard converts the PC PS/2 port of KVM switch to USB port (PC or SUN platforms
$8.99
Buy on Amazon
命令
基本用法
用途与注意事项
dir
dir
列出当前目录的文件和子目录。
cd、chdir
cd /d D:Projects
切换当前目录;跨驱动器时使用 /d。
md、mkdir
mkdir C:WorkReports
创建目录,路径含空格时加引号。
rd、rmdir
rmdir C:WorkEmptyFolder
删除目录;/s 会连同子目录内容一起删除。
copy
copy report.txt D:Backup
适合简单文件复制。
xcopy
xcopy C:Work D:BackupWork /e /i
支持目录树复制;执行前确认源路径和目标路径。
robocopy
robocopy C:Work D:BackupWork /e /z /log:copy.log
更适合大批量、可恢复并需要记录日志的文件复制。
move
move report.txt D:Archive
移动文件或目录。
ren
ren old-name.txt new-name.txt
重命名文件或目录。
del、erase
del /p "C:Temp*.tmp"
删除文件;/f 强制删除只读文件,/s 处理子目录,/q 取消确认。
type
type notes.txt
显示文本文件内容,不适合查看二进制文件。
more
type long-log.txt | more
分页查看较长的文本输出。
微软的dir 命令文档说明了递归、隐藏项目、简洁输出和排序等常用选项。常用示例包括:
dir /a
dir /s "C:Work*.log"
dir /b /s "C:Work*.txt"
dir /o:-d
/a 把隐藏和系统项目也纳入显示。
/s 递归搜索子目录。
/b 仅输出名称,适合后续管道处理。
/o:-d 按日期倒序排序。
删除前可以先执行完全相同的搜索条件:
dir /s "C:Temp*.log"
确认清单后再决定是否执行 del。不要在未知目录中直接运行 del /s /q *.*,也不要未经确认运行 rmdir /s。
del 官方文档明确列出了递归、强制和静默删除参数。CMD 删除文件后通常不能从命令行撤销,重要文件应先备份。
CMD 如何处理文本和批处理脚本
CMD 环境变量通常使用 %变量名% 展开。环境变量属于当前命令解释器环境;新的子 cmd 实例会继承父进程环境,但子实例中的修改不会反向影响父进程。
echo Hello
set NAME=Alex
echo %NAME%
set
批处理文件建议使用 setlocal 和带引号的赋值格式,避免变量值末尾意外包含空格:
@echo off
setlocal
set "LOG=C:Temprun.log"
echo Started>>"%LOG%"
endlocal
find、findstr、sort 和 more 可以对文本输出进行筛选、排序和分页:
findstr /i "error failed" app.log
findstr /s /i /n "TODO" *.js
some-command | sort | more
findstr 适合快速搜索日志和源文件;复杂文本处理、结构化数据、对象筛选、远程管理和跨平台自动化通常更适合 PowerShell。
批处理中的条件、循环和调用
命令
示例
用途
if
if exist report.txt echo Found
判断文件或条件是否成立。
for
for %%F in (*.log) do echo %%F
遍历文件或一组值。
call
call backup.cmd
从一个批处理脚本调用另一个脚本或标签。
goto
goto :label
跳转到批处理文件中的标签。
if errorlevel
if errorlevel 1 echo Command failed
根据命令返回状态判断是否失败。
在批处理文件中,for 的变量通常写成 %%F;在交互式命令提示符中则通常写成 %F。call 主要用于脚本之间的调用,在脚本外的交互式命令提示符中使用时,并不具有同样的批处理脚本调用效果。可参考微软的call 命令文档。
Also popular on Amazon
XIAOQENAN USB To Keyboards Adapter Keyboards To USB Adapter For And Keyboard Compatibility With Desktops And Laptops
connecting your USB or keyboard to Keyboards port with the USB to Keyboards Adapter, for computers lacking USB interfaces.This adapter features a USB male connectors on 1end and Keyboards female connectors on the other, crafted from durability ABS for long last use without the need for additional driver.Suitable for enthusiasts and professional who frequently work with older computer systems or need to optimizes limited USB port.Use this adapter in office environment, home setups, or any situation where you need to connecting Keyboards devices to modern computers, ensuring seamlessly integration and functionality.Designs to save valuable USB port, this compactly converters is essential accessory for maintaining compatibility between peripherals and contemporary hardware.
$5.99
Buy on Amazon
哪些 CMD 命令用于系统信息和维护
系统维护命令的共同特点是可能需要管理员权限、运行时间较长,或改变文件系统、组件存储和正在运行的进程。先收集信息,再选择修复动作,比直接执行“万能修复命令”更安全。
命令
示例
主要作用
关键风险
ver
ver
显示 Windows 版本信息。
输出较简略,不能替代完整系统信息。
systeminfo
systeminfo
输出系统配置、补丁和启动信息。
输出可能受权限、版本和系统语言影响。
set
set
查看当前 CMD 环境变量。
输出可能包含用户名、路径或企业环境信息。
sfc
sfc /scannow
扫描受保护系统文件,并在可能时替换错误版本。
通常需要管理员权限;不能解决所有 Windows 故障。
DISM
DISM /Online /Cleanup-Image /RestoreHealth
管理 Windows 映像和组件存储。
修复可能耗时较长,应匹配当前 Windows 版本。
chkdsk
chkdsk C: /f
检查卷和文件系统状态,并尝试修复错误。
可能需要锁定卷或安排下次重启;先备份重要数据。
tasklist
tasklist /svc
查看运行中的进程和服务关联。
诊断输出可能包含敏感的进程信息。
taskkill
taskkill /pid 1234 /f
按 PID 或映像名终止进程。
/f 可能导致未保存数据丢失。
shutdown
shutdown /r /t 60 /c "Maintenance restart"
计划关机或重启,也可以取消。
远程或生产环境中可能中断工作和服务。
sfc、DISM 和 chkdsk 应该怎样使用
sfc /scannow 会扫描并尝试修复受保护系统文件;sfc /verifyonly 只检查而不修复。离线系统可以进一步使用 /offwindir、/offbootdir 等参数,但离线路径必须对应实际的 Windows 安装位置。
sfc /verifyonly
sfc /scannow
微软的sfc 官方文档提供了在线和离线参数。执行 sfc /scannow 前,应确认命令提示符以管理员身份运行,并在完成后查看命令输出、日志和错误码。
DISM 常见的检查和修复顺序如下:
DISM /Online /Cleanup-Image /CheckHealth
DISM /Online /Cleanup-Image /ScanHealth
DISM /Online /Cleanup-Image /RestoreHealth
CheckHealth、ScanHealth 和 RestoreHealth 的工作量不同,RestoreHealth 可能需要较长时间。完成 DISM 后,常见做法是重新运行 sfc /scannow,但每种故障都不必机械执行完整流程。
chkdsk C: 用于检查卷,chkdsk C: /f 尝试修复文件系统错误,chkdsk C: /scan 执行在线扫描。磁盘或文件系统存在异常时,修复前应优先备份重要数据。
如何安全使用进程和关机命令
tasklist
tasklist /svc
taskkill /pid 1234 /f
taskkill /im notepad.exe
shutdown /s /t 0
shutdown /r /t 60 /c "Maintenance restart"
shutdown /a
taskkill /f 会强制终止进程,可能丢失未保存数据。shutdown /s /t 0 会立即关机,shutdown /r /t 60 会在 60 秒后重启,shutdown /a 可以取消尚未执行的关机或重启。执行前必须确认目标设备、当前用户权限和命令中的延迟时间。
哪些 CMD 命令用于网络诊断
网络排查应从本机配置开始,再依次检查地址、连通性、路径、DNS 和端口。单个命令失败通常只能说明一个环节异常,不能直接证明整个网络或目标服务不可用。
命令
示例
可观察内容
不能单独证明什么
ipconfig
ipconfig /all
网卡、IPv4/IPv6 地址、默认网关和 DNS 配置。
配置正常不代表互联网服务一定正常。
ping
ping example.com
基本连通性和延迟。
ICMP 被阻止时,失败不必然表示服务不可用。
tracert
tracert example.com
到目标的网络路径。
中间节点不回应不一定代表后续路径中断。
pathping
pathping example.com
路径信息和丢包统计。
统计需要时间,结果仍受网络策略影响。
nslookup
nslookup -type=MX example.com
DNS 记录和 DNS 服务器响应。
DNS 正常不代表应用端口可连接。
netstat
netstat -ano
连接、监听端口和关联 PID。
端口本身不能单独证明存在恶意活动。
常用网络诊断命令
ipconfig
ipconfig /all
ipconfig /flushdns
ipconfig /release
ipconfig /renew
ping 8.8.8.8
ping example.com
tracert example.com
pathping example.com
nslookup example.com
nslookup -type=MX example.com
netstat -ano
netstat -ano | findstr LISTENING
tasklist /fi "PID eq 1234"
ipconfig /flushdns 会清除 DNS 客户端缓存。ipconfig /release 和 ipconfig /renew 会影响当前网络连接,只应在明确需要重新获取地址时执行。
netstat -ano 显示端口和 PID 后,可以使用 tasklist /fi "PID eq 1234" 查找关联进程。端口排查还应结合进程路径、数字签名、服务配置和安全日志,不能只凭一个监听端口判断恶意活动。
Also popular on Amazon
YARCHONN USB to PS/2 Converter Adapter Keyboard Cable 18cm | PS2 Female Keyboard Mouse Interface to USB 2.0 Male Connector Cord for Desktop Laptop 2pcs
USB to PS/2 Keyboard Converter Cable used for computers,this cable can effectively solve the problem of your computer only having a USB port without a PS/2 keyboard port.This PS2 Female to USB Male Adapter supports connecting devices with PS/2 interfaces such as keyboards, mice, PS/2 barcode scanners, etc.The USB to PS/2 Keyboard Converter Adapter Cable is equipped with a high-performance chip, which connects a keyboard and mouse with a PS2 port to a computer without lag or delay.USB to PS/2 adapter Cable does not require driver installation and is plug and play, convenient and fast.The cable is composed of PVC material and oxygen free copper core, which is sturdy, durable, stable and fast in transmitting signals.
$8.99
Buy on Amazon
如何用 CMD 启动程序、提升权限和查找命令
start、runas、where、path、assoc 和 ftype 分别覆盖程序启动、指定账户运行、可执行文件定位、PATH 查看以及文件关联排查。
为什么 start 的路径前面经常要写两个引号
start 把第一个加引号的参数当作窗口标题,而不是程序路径。因此,路径含空格时应使用空标题再写实际路径:
start "" "C:Program FilesAppapp.exe"
start "Browser" "https://example.com"
start /wait setup.exe
start /wait 会等待启动的程序结束后再继续执行后续脚本。微软的start 文档页面标注的最后更新时间为 2026 年 4 月 16 日;文档还说明,/machine 在 Windows 11 中属于预览性质,不能假设所有环境都适用。
如何排查“不是内部或外部命令”
where python
path
assoc .txt
ftype txtfile
where 可以定位可执行文件,path 显示当前 PATH,assoc 查看扩展名关联,ftype 查看文件类型关联。遇到“不是内部或外部命令”时,应依次检查拼写、当前目录、PATH 环境变量,以及实际可执行文件是否存在。
runas 可以尝试以指定用户身份运行程序,例如:
runas /user:Administrator cmd
runas 是否成功取决于账户、凭据、UAC、组织策略和管理员权限。不要在脚本中硬编码密码;需要管理员权限时,应确认命令提示符窗口标题、目标计算机和完整命令内容。
Independent reader supportYour contribution helps us test, update, and keep practical guides available for everyone.Support on Ko-FiCMD 和 PowerShell 有什么区别
CMD 主要处理传统文本命令和批处理,PowerShell 更适合对象、结构化数据、模块化脚本、远程管理和复杂自动化。PowerShell 可以运行许多 Windows 原生命令,但“能在 PowerShell 窗口运行”不等于命令就是 PowerShell 命令。
比较维度
CMD
PowerShell
主要定位
传统命令解释器和批处理环境
命令行 shell、脚本语言和自动化框架
输出处理
主要以文本管道和重定向处理输出
更适合处理 .NET 对象和结构化输出
适合任务
运行 .bat、.cmd,兼容旧软件,执行简单命令
复杂筛选、系统管理、远程管理和模块化自动化
脚本扩展
.bat、.cmd
通常使用 PowerShell 脚本和模块
跨平台能力
主要面向 Windows 传统环境
更适合需要跨平台的自动化场景
相同名称陷阱
type 是 CMD 的文本显示命令
type 可作为 Get-Content 的别名,但参数和语义体系不同
传统安装脚本、旧批处理和简单的 dir、copy、del、ipconfig 操作优先使用 CMD。需要对象化数据、复杂条件、远程计算机管理或可维护的自动化脚本时,PowerShell 通常是更合适的选择。
希望系统学习 CMD、批处理和 Windows 命令行管理的读者,可以把Windows 命令行管理书作为可选学习资料。该链接提供的是书目元数据,本次资料没有确认具体 Amazon 商品页面、价格、库存或评价;微软官方文档和当前系统的 /? 帮助仍应作为首要参考。
Also popular on Amazon
USB Hub 4 Port, USB Splitter 1 in 4 Out, USB Extender Hub for Laptop PC | Multiport USB Adapter, Expands One USB Port into Four with USB 3.0 5Gbps Data Transfer Comaptible for Desktop PS Xbox
【4 Ports USB Port Hub】:Expand one USB-A port into four USB ports with VIENON USB splitter 1 in 4 out. Connect keyboards, mice, flash drives, printers, card readers and other USB devices to your laptop or desktop easily.【5Gbps USB 3.0 Fast Data Transfer】:This USB adapter includes a USB 3.0 data port with transfer speeds up to 5Gbps, helping you move photos, files and videos faster than USB 2.0. Additional USB ports are suitable for keyboard, mouse, printer and other standard USB accessories.【Plug and Play, No Driver Needed】:No software or external driver is required. Just plug the USB multiport adapter into your computer and start using it. Compatible with Windows, macOS, Linux, laptops, desktops, Xbox, PS4 and more USB-A host devices.【Ultra Slim and Travel Friendly】:The compact usb hub for laptop features a slim body that saves desk space and fits easily in a laptop bag, backpack or office drawer. The spacing between USB ports is designed for common USB devices, allowing multiple connections at the same time.【LED Indicator and Daily Use Design】:A soft blue LED indicator lets you quickly check working status without being too bright. Please note: this usb multiport adapter is designed for data transfer and low-power peripherals only. It does not support charging laptops, tablets or high-power devices.
$5.99
Buy on Amazon
2026 年 Windows 11 更新会改变 CMD 命令吗
截至 2026 年 8 月 12 日,微软Windows 11 release information 页面列出的通用可用版本包括 26H1、25H2 和 24H2。该页面列出的 2026 年 7 月 B 更新构建如下:
Windows 11 版本
定位
2026 年 7 月 B 更新构建
26H1
面向 2026 年初上市新设备的硬件优化版本
28000.2525
25H2
通用可用功能版本
26200.8875
24H2
通用可用功能版本
26100.8875
Windows 11 26H1 不是面向现有 24H2 或 25H2 电脑提供的就地功能更新,因此不能因为看到 26H1 就假设现有设备会自动升级到 26H1。微软通常每年发布一次功能更新,并在每月第二个星期二发布累积安全更新。
家庭版和专业版等 Windows 版本通常有 24 个月支持期,企业版和教育版通常有 36 个月支持期;具体支持终止日期应以微软 release information 页面为准,而不应只依据第三方文章的年份判断。Windows 11 版本问题还可以通过微软的26H1 known issues and notifications 页面核对。
版本更新不会自动意味着所有传统 CMD 命令都被删除或改变。更稳妥的做法是针对目标电脑运行 命令 /?,阅读对应的 Microsoft Learn 文档,并在批处理脚本中检查 %ERRORLEVEL% 或命令返回状态。不同版本、权限和恢复环境可能支持不同参数。
使用 CMD 命令的安全排查顺序
下面的顺序适用于一般的 Windows 信息收集、文件排查、系统维护和网络诊断;生产环境、远程设备和重要数据应先建立备份与变更回滚方案。
先收集只读信息。 优先使用 ver、systeminfo、ipconfig /all、tasklist 和 dir,确认 Windows 版本、网络配置、进程和文件位置。
先看帮助再执行参数。 对每个陌生命令运行 命令 /?,确认当前系统是否支持参数以及参数的精确语义。
优先使用预览或检查模式。 删除前用 dir 检查清单;修复系统文件前可先使用 sfc /verifyonly;磁盘修复前先备份重要数据。
核对管理员权限和目标。 执行 sfc、DISM、chkdsk、taskkill /f 或 shutdown 前,确认窗口标题、目标卷、计算机和命令内容。
特别警惕不可逆或中断性命令。 del /s /q、rmdir /s、taskkill /f、磁盘修复和立即关机都可能造成数据丢失或工作中断。
保存日志但先脱敏。 使用 > 或 >> 保存诊断输出时,应注意输出可能包含用户名、计算机名、IP 地址、目录路径和其他个人或企业信息。
自动化复杂后及时换工具。 当条件、循环、错误处理和结构化数据让 CMD 脚本难以维护时,应评估 PowerShell,而不是继续把逻辑塞进批处理。
Windows CMD 命令速查表
下表汇总最常用的 Windows CMD 命令。表格用于快速定位任务,不代表某个 Windows 版本的绝对完整清单;实际参数仍应通过对应的 命令 /? 确认。
任务
命令
典型用途
查看目录
dir
列出文件和子目录
切换目录
cd、chdir
改变当前工作目录
创建目录
mkdir、md
新建文件夹
复制文件
copy、xcopy、robocopy
复制文件或目录树
移动和改名
move、ren
移动或重命名
删除文件
del、erase
删除文件,需先确认目标
查看文本
type、more
输出或分页查看文本
搜索文本
find、findstr
在文件或管道输出中查找文本
查看系统
ver、systeminfo
查看版本和系统配置
系统文件
sfc
检查受保护系统文件
Windows 映像
DISM
检查或修复组件存储
磁盘文件系统
chkdsk
检查或修复卷错误
网络地址
ipconfig
查看和刷新网络配置
连通性
ping
测试基本连通性
路由路径
tracert、pathping
查看路径和丢包情况
DNS
nslookup
查询 DNS 记录和服务器响应
端口和 PID
netstat -ano
查看连接、监听端口及 PID
进程
tasklist、taskkill
查看或终止进程
关机重启
shutdown
计划或取消关机、重启
启动程序
start
启动程序、窗口或 URL
查找可执行文件
where
定位命令实际路径
查看环境变量
set、path
查看或处理 CMD 环境
文件关联
assoc、ftype
查看扩展名和文件类型关联
本文没有声称对每条 Windows 命令进行实际运行测试。命令行为、输出内容和可用参数应在读者自己的 Windows 版本、账户权限、恢复环境和目标设备上验证。
Frequently Asked Questions
Windows CMD 命令大全不能用一张固定清单覆盖所有 Windows 命令,因为可用参数会受 Windows 版本、Server 版本、恢复环境和权限影响。使用具体命令后加 /?,例如 dir /?,才能确认当前系统支持的参数。
Windows CMD 命令大全是否包含 Windows 的所有命令?
del /s /q、rmdir /s、taskkill /f、磁盘修复命令和 shutdown 都需要特别谨慎。删除前先用 dir 查看目标,强制终止前保存工作,磁盘修复前备份重要数据,并在关机或重启前确认目标设备。
CMD 中最危险的命令有哪些?
ping 失败不一定说明目标服务不可用,因为 ICMP 可能被防火墙或目标网络阻止。应结合 ipconfig /all、nslookup、tracert 或 pathping 区分本机配置、DNS、路由和目标策略问题。
ping 失败是不是说明 Windows 没有网络?
CMD 适合传统 .bat、.cmd 脚本、旧软件兼容和简单文本命令;PowerShell 更适合对象处理、结构化输出、远程管理和复杂自动化。PowerShell 能运行许多 Windows 原生命令,但同名命令的参数和语义不一定相同。
CMD 和 PowerShell 可以互相替代吗?
The Bottom Line
Windows CMD 命令大全应当被视为按任务分类的使用地图,而不是永恒不变的“所有命令”列表。先用只读命令和 命令 /? 确认环境,再谨慎执行删除、修复、强制终止和关机操作;当脚本需要复杂自动化时,改用 PowerShell。
Quick Recap
Bestseller No. 1
Perixx PERIPRO-401 PS2 to USB Adapter for Keyboard and Mouse - Built-in USB Controller - Black
UNIVERSAL PURPOSES: Fits with industrial and professional needs; PACKAGE INCLUDES: Perixx PERIPRO-401 adapter, manual; 12-month limited
$8.99
Bestseller No. 2
UCEC PS/2 to USB Adapter Converter for PS2 Keyboard Mouse Accessories | USB to Dual PS/2 Cables Accessories (Black)
$8.99
Bestseller No. 3
XIAOQENAN USB To Keyboards Adapter Keyboards To USB Adapter For And Keyboard Compatibility With Desktops And Laptops
$5.99
Bestseller No. 4
YARCHONN USB to PS/2 Converter Adapter Keyboard Cable 18cm | PS2 Female Keyboard Mouse Interface to USB 2.0 Male Connector Cord for Desktop Laptop 2pcs
$8.99
Bestseller No. 5
USB Hub 4 Port, USB Splitter 1 in 4 Out, USB Extender Hub for Laptop PC | Multiport USB Adapter, Expands One USB Port into Four with USB 3.0 5Gbps Data Transfer Comaptible for Desktop PS Xbox
$5.99
Product prices and availability are accurate as of the date/time indicated and are subject to change. Any price and availability information displayed on Amazon at the time of purchase will apply. Prices as of November 8, 2026 7:25 am GMT+0530.Brands and makersPut your product in front of the readers of this article.Sponsor this postFreedom251 newsletterMore Windows 11 guides like this, every weekOne short e-mail a week. Free, no spam — unsubscribe in one click.E-mail addressJoin freeYour address stays with us — privacy. CMD命令PowerShellWindows 11Windows CMD命令提示符批处理系统维护网络诊断