將以下內容存為 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% (使用者設定檔)。同樣邏輯可用 VBScript/PowerShell 實作,批次檔相容性最好(XP 至 Win10 皆可跑),但腳本執行可能遇到 Windows Script Host 錯誤。