Windows XP Windows 7 Windows 2003 Windows Vista Windows 綜合教學 Linux 系統教學
Windows 10 Windows 8 Windows 2008 Windows NT Windows Server 電腦軟體教學

Windows 底層 DOS 指令全景:從 cmd 到系統呼叫的運作原理

編輯:系統常見問題解答

Windows 作業系統提供命令列介面 (CLI) 讓使用者透過文字指令與核心互動。本文概述常用內建指令分類、查詢方式與指令執行流程。

如何查看所有內建指令

  1. Win+R → cmd → Enter
  2. 切換至系統目錄:cd /d %SystemRoot%\System32
  3. 輸入 help 列出所有指令;或 help | more 分頁顯示。

主要指令分類

類別代表指令用途
檔案/目錄管理dir, copy, move, del, md, rd, xcopy, robocopy檔案複製、移動、刪除、目錄建立/移除
磁碟/分割區format, chkdsk, diskpart, defrag, label, vol格式化、檢查、分割區管理、碎片整理
系統資訊/設定systeminfo, msinfo32, dxdiag, gpupdate, gpresult, tasklist, taskkill硬體/軟體資訊、群組原則、進程管理
網路診斷ping, ipconfig, netstat, tracert, nslookup, netsh, route, arp連線測試、IP 設定、埠號/路由/ARP 表查詢
服務/程序控制sc, net start/stop, schtasks, at, shutdown服務安裝/啟動/停止、排程工作、關機
登錄檔操作reg add/delete/query/export/import命令列讀寫登錄檔
環境/變數set, setx, path, prompt, title環境變數顯示/設定、提示字元自訂

指令執行流程

  1. 使用者在 cmd.exe 輸入指令字串按 Enter。
  2. cmd.exe 解析字串,區別內建指令 (Internal Commands:dir, cd, set 等) 與外部程式 (External Commands:.exe, .bat, .com)。
  3. 內建指令直接由 cmd.exe 進程執行;外部程式則建立子進程執行對應映像檔。
  4. 作業系統核心 (ntoskrnl.exe) 透過系統呼叫 (System Calls) 提供檔案 I/O、程序管理、記憶體管理等服務。
  5. 執行結果透過標準輸出/錯誤輸出回傳至主控台視窗。

這與 Linux Shell (bash/zsh) 架構相似:cmd.exe 對應 Shell,系統呼叫對應 Kernel API。差異在於 Windows 採用 Win32 API / Native API,Linux 採用 POSIX / syscall。

Copyright © Windows教程網 All Rights Reserved