萬盛學電腦網

您现在的位置: 萬盛學電腦網 >> 電腦基礎知識 >  >> 電腦基本常識

30 秒自製「系統垃圾清理器」:一鍵掃除臨時檔、Log、快取

為什麼要定期清理?

Windows 長期運行會產生大量暫存檔(*.tmp, *._mp)、記錄檔(*.log)、說明檔(*.gid)、磁碟檢查殘留(*.chk)、備份檔(*.old, *.bak)以及 IE/Edge 快取。這些垃圾不僅佔用百 MB 甚至 GB 空間,還會拖慢檔案總管索引、讓系統變慢。

兩步驟建立專屬清理腳本

步驟 1:建立批次檔

  1. 按 Win → 輸入「記事本」 → Enter。
  2. 複製下方完整程式碼貼上。
  3. 點選「檔案」→「另存新檔」→ 存放位置選「桌面」→ 檔名 清除系統垃圾.bat → 存檔類型選「所有檔案」 → 存檔。

步驟 2:以系統管理員身分執行

  1. 桌面找到 清除系統垃圾.bat。
  2. 滑鼠右鍵 →「以系統管理員身分執行」。
  3. 命令提示字元視窗跑完顯示「清除系統垃圾完成!」即可關閉。

批次檔完整內容(可直接複製)

@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%\*.bak
del /f /s /q %systemdrive%\$Recycle.Bin\*.*
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% 通常為 C:;%windir% 為 Windows 目錄;%userprofile% 為目前使用者資料夾。

進階:排程自動執行

  1. 開啟「工作排程器」→「建立基本工作」。
  2. 觸發條件選「每週」或「每月」。
  3. 動作:「啟動程式」→ 瀏覽選取桌面的 清除系統垃圾.bat → 勾選「使用最高權限執行」。

以後系統就會定期自動瘦身,保持輕快!

copyright © 萬盛學電腦網 all rights reserved