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

Win7 命令提示字元所有 DOS 指令失效?PATH 環境變數被竄改修復

編輯:Windows 7 系統介紹

故障現象

CMD 執行任何指令 (ping/ipconfig/dir) 均提示:
'xxx' 不是內部或外部指令、可執行的程式或批次檔。

原因

某軟體 (如暴風影音/格式工廠/驅動精靈) 安裝時修改系統 Path 環境變數,刪除或覆蓋原有系統路徑 (%SystemRoot%\System32 等),導致系統找不到核心執行檔。

修復步驟

  1. 右鍵「電腦」→「內容」→「進階系統設定」→「環境變數」。
  2. 「系統變數」區找到 Path,編輯檢查內容。若發現被改為類似 C:\Program Files (x86)\StormII\Codec;C:\Program Files (x86)\StormII 且缺少系統路徑。
  3. 在變數值**最前面**加入:
    %SystemRoot%\System32;%SystemRoot%;%SystemRoot%\System32\Wbem;%SystemRoot%\System32\WindowsPowerShell\v1.0\
  4. 確定所有對話框,重新開啟 CMD 驗證指令恢復正常。

預防建議

  • 安裝軟體時選擇「自訂安裝」,取消勾選「加入系統 Path」等選項。
  • 定期備份環境變數 (PowerShell: [Environment]::GetEnvironmentVariable('Path','Machine') 匯出)。
  • 使用 Rapid Environment Editor 等圖形化工具管理環境變數,直觀且支援撤銷。
Copyright © Windows教程網 All Rights Reserved