掌握 CMD 指令是邁向 Windows 高手的必經之路。本文整理 100+ 高頻實用指令,按功能分類並附參數說明,建議收藏備查。適用 Windows 7/8/10/11/Server 全系列。
winver - Windows 版本號對話框systeminfo - 詳細系統資訊 (可 `> info.txt` 輸出)msinfo32 - 圖形化系統資訊dxdiag - DirectX 診斷工具control - 控制台msconfig - 系統設定 (啟動項、服務、開機選項)gpedit.msc - 群組原則編輯器 (Pro/Enterprise)secpol.msc - 本機安全性原則regedit / regedt32 - 登錄編輯器services.msc - 服務管理compmgmt.msc - 電腦管理 (裝置、磁碟、事件、共用)devmgmt.msc - 裝置管理員diskmgmt.msc - 磁碟管理dfrg.msc - 磁碟重組perfmon.msc - 效能監視器eventvwr.msc - 事件檢視器rsop.msc - 群組原則結果集ipconfig /all - 完整網路設定ping -t 8.8.8.8 - 持續測試連線tracert google.com - 路由追蹤nslookup google.com - DNS 解析測試netstat -an - 所有連線/埠口狀態netsh interface ip show config - 介面 IP 設定netsh wlan show profiles - Wi-Fi 設定檔netsh wlan show profile name="SSID" key=clear - 顯示 Wi-Fi 密碼chkdsk C: /f /r - 掃描修復磁碟錯誤 (需重開機)sfc /scannow - 系統檔案完整性檢查修復dism /online /cleanup-image /restorehealth - 元件存儲修復 (Win8+)cleanmgr - 磁碟清理defrag C: /u /v - 磁碟重組 (SSD 勿用)cipher /w:C: - 擦除可用空間 (防資料恢復)compact /c /s:C:\Folder - NTFS 壓縮資料夾tasklist - 列出程序taskkill /pid 1234 /f - 強制結束程序taskkill /im notepad.exe /f - 依名稱結束net stop wuauserv - 停用 Windows Updatenet start wuauserv - 啟用 Windows Updatesc query state= all - 列出所有服務狀態shutdown /s /t 0 - 立即關機shutdown /r /t 0 - 立即重開機shutdown /a - 取消關機lusrmgr.msc - 本機用戶和群組net user - 列出用戶net user username newpass - 修改密碼net localgroup administrators username /add - 加入管理員群組runas /user:administrator cmd - 以其他用戶身分執行notepad、calc、mspaint、snippingtool、osk (螢幕鍵盤)、magnify (放大鏡)、narrator (螢幕朗讀)、write (WordPad)@echo off
setlocal enabledelayedexpansion
rem 變數: set var=value, 使用 %var% 或 !var!
rem 判斷: if "%var%"=="value" (cmd) else (cmd)
rem 迴圈: for %%i in (files) do cmd
rem 參數: %1 %2 ... %9, %* (全部)
rem 返回碼: %errorlevel%
| CMD | PowerShell |
|---|---|
| ipconfig | Get-NetIPConfiguration |
| ping | Test-Connection |
| netstat | Get-NetTCPConnection |
| tasklist | Get-Process |
| taskkill | Stop-Process |
| services.msc | Get-Service |
| dir | Get-ChildItem |
| copy/move/del | Copy-Item/Move-Item/Remove-Item |