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

Win7 執行 BAT 批次檔顯示亂碼怎麼辦?另存為 ANSI 編碼解決

編輯:Win7 系統應用技巧

Windows 7 雙擊執行 .bat 批次檔時,若中文顯示亂碼 (如 、),原因是批次檔以 UTF-8 編碼儲存,但 CMD 預設代碼頁為 936 (GBK/ANSI),無法正確解碼 UTF-8。將檔案編碼轉為 ANSI 即可解決。

解決步驟

  1. 右鍵 .bat 檔案 → 「編輯」 (用記事本開啟)。
  2. 點擊「檔案」→「另存新檔」。
  3. 「編碼」下拉選單選擇 ANSI (非 UTF-8、Unicode、UTF-8 with BOM)。
  4. 「儲存類型」選「所有檔案」→ 檔名保持 xxx.bat → 「儲存」覆蓋原檔。
  5. 重新雙擊執行 .bat,中文應正常顯示。

補充說明

  • 若使用 Notepad++、VS Code 等進階編輯器,可在右下角/選單直接切換編碼為「ANSI」/「GBK」/「Chinese Simplified (GB2312)」後存檔。
  • 若批次檔需在 UTF-8 環境執行 (如 PowerShell Core、Linux wine),可在檔案開頭加入 chcp 65001 切換代碼頁,但 Win7 CMD 原生不完整支援 UTF-8 顯示中文。
  • 此問題同樣適用於 .cmd、.vbs 等腳本檔案。
Copyright © Windows教程網 All Rights Reserved