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

WinXP 一鍵清理系統垃圾:批次檔腳本完整代碼與使用教學

編輯:XP 系統應用技巧

不想裝第三方清理軟體,又想徹底清除暫存檔、記錄檔、回收站、預讀資料、Cookie 等系統垃圾?一個批次檔 (.bat) 就能搞定。本文提供可直接複製的完整腳本代碼、建立步驟、參數說明與注意事項,讓您在 WinXP/XP/Win7/Win10 通用的乾淨環境中輕鬆維護系統。

建立清理批次檔

  1. 開啟「記事本」 (notepad)。
  2. 複製下方完整代碼貼上 (請勿手打,避免錯字)。
  3. 「檔案」→「另存新檔」→ 檔名輸入 系統清理.bat (副檔名必須為 .bat) → 存檔類型選「所有檔案」 → 存放桌面或常用資料夾。

完整批次腳本代碼

@echo off
echo 正在清除系統垃圾檔案,請稍候......
del /f /s /q %systemdrive%\*.tmp
del /f /s /q %systemdrive%\*._mp
del /f /s /q %systemdrive%\*.log
del /f /s /q %systemdrive%\*.gid
del /f /s /q %systemdrive%\*.chk
del /f /s /q %systemdrive%\*.old
del /f /s /q %systemdrive%\recycled\*.*
del /f /s /q %windir%\*.bak
del /f /s /q %windir%\prefetch\*.*
rd /s /q %windir%\temp & md %windir%\temp
del /f /q %userprofile%\cookies\*.*
del /f /q %userprofile%\recent\*.*
del /f /s /q "%userprofile%\Local Settings\Temporary Internet Files\*.*"
del /f /s /q "%userprofile%\Local Settings\Temp\*.*"
del /f /s /q "%userprofile%\recent\*.*"
echo 系統垃圾清除完成!
pause

參數與目錄說明

指令清理目標備註
*.tmp系統暫存檔全磁碟遞迴刪除
*._mp媒體播放暫存
*.log記錄檔
*.gid說明檔索引
*.chk磁碟掃描碎片
*.old備份舊檔
recycled\*.*回收站 (FAT32)NTFS 為 RECYCLER,若不想清回收站可刪此行
prefetch\*.*預讀快取重開機後系統會自動重建
temp 目錄重建系統暫存資料夾先刪除再新建,避免權限問題
cookies\*.*Cookie/登入狀態若想保留登入密碼,請刪除此行
recent\*.*最近使用文件捷徑
Temporary Internet FilesIE 快取/網頁暫存
Local Settings\Temp使用者暫存資料夾

使用方法與注意事項

  1. 雙擊 系統清理.bat 執行,視檔案數量跑幾秒到數分鐘。
  2. 出現「請按任意鍵繼續...」表示完成,關閉視窗即可。
  3. 以系統管理員身分執行 (右鍵批次檔 → 「以系統管理員身分執行」) 可清理更多受保護目錄 (WinXP 需確認為 Administrator 群組)。
  4. 建議每週執行一次,或在安裝/解除安裝大型軟體後執行。
  5. 此腳本不會刪除個人文件 (我的文件、桌面、下載等),僅清理系統判定為可安全移除的暫存/快取/記錄檔。

進階:加入排程自動執行

  1. 「控制台」→「排程工作」→「新增排程工作」。
  2. 瀏覽選取 系統清理.bat → 設定每週/每月執行時間 → 輸入帳號密碼確認。
  3. 系統將在背景自動清理,無需人工干預。

一個批次檔,替代付費清理軟體,讓 WinXP 長期保持輕快乾淨。

Copyright © Windows教程網 All Rights Reserved