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

Windows 系統垃圾清理批次檔:一鍵刪除暫存檔、記錄檔與回收站

編輯:XP 系統應用技巧

批次檔內容

將以下內容存為 cleanup.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

參數說明

  • /f 強制刪除唯讀檔,/s 遞迴子目錄,/q 安靜模式不提示確認。
  • 環境變數:%systemdrive% (系統磁碟)、%windir% (Windows 目錄)、%userprofile% (使用者設定檔)。
  • 涵蓋:暫存檔、記錄檔、索引檔、檢查點檔、備份檔、Prefetch、回收站、Cookies、近期使用、IE 快取、使用者 Temp。

替代方案

同樣邏輯可用 VBScript/PowerShell 實作,批次檔相容性最好(XP 至 Win10 皆可跑),但腳本執行可能遇到 Windows Script Host 錯誤。

Copyright © Windows教程網 All Rights Reserved