【批处理】一键清理系统垃圾
@echo off
color 0A
title 一键清理系统垃圾 + 全浏览器缓存 (兼容 WinXP/7/10/11)
cls
echo.
echo =========================================================================
echo 一键清理系统垃圾 + 全浏览器缓存 (兼容 WinXP/7/10/11)
echo =========================================================================
echo 说明:
echo 本批处理脚本将运行清理系统临时文件、更新缓存、缩略图等命令,
echo 并彻底清理 IE、Edge、谷歌 Chrome、火狐 Firefox 的网页缓存。
echo
echo 注意:为了保证清理彻底,脚本会强制关闭正在运行的浏览器。
echo 请确保您已保存好浏览器中的重要工作!
echo 请确保您已保存好浏览器中的重要工作!
echo 请确保您已保存好浏览器中的重要工作!
echo =========================================================================
echo.
pause
echo.
echo [1/8] 正在强制关闭所有浏览器进程 (Chrome/Edge/Firefox/IE)...
taskkill /F /IM chrome.exe >nul 2>&1
taskkill /F /IM msedge.exe >nul 2>&1
taskkill /F /IM firefox.exe >nul 2>&1
taskkill /F /IM iexplore.exe >nul 2>&1
timeout /t 2 /nobreak >nul
echo [2/8] 正在清理系统盘根目录临时文件...
:: 修改点:去掉了 /s 参数,只清理根目录,防止遍历全盘导致卡死
del /f /q %systemdrive%\*.tmp >nul 2>&1
del /f /q %systemdrive%\*._mp >nul 2>&1
del /f /q %systemdrive%\*.log >nul 2>&1
del /f /q %systemdrive%\*.gid >nul 2>&1
del /f /q %systemdrive%\*.chk >nul 2>&1
del /f /q %systemdrive%\*.old >nul 2>&1
del /f /q %systemdrive%\recycled\*.* >nul 2>&1
del /f /q %systemdrive%\$Recycle.Bin\*.* >nul 2>&1
echo [3/8] 正在清理 Windows 系统目录垃圾...
del /f /s /q %windir%\*.bak >nul 2>&1
del /f /s /q %windir%\*.tmp >nul 2>&1
del /f /s /q %windir%\prefetch\*.* >nul 2>&1
rd /s /q %windir%\temp & md %windir%\temp >nul 2>&1
del /f /s /q %windir%\SoftwareDistribution\Download\*.* >nul 2>&1
del /f /s /q %windir%\Logs\*.* >nul 2>&1
rd /s /q %windir%\Logs\CBS >nul 2>&1 & md %windir%\Logs\CBS >nul 2>&1
echo [4/8] 正在清理用户临时文件和缓存...
del /f /s /q "%TEMP%\*.*" >nul 2>&1
rd /s /q "%TEMP%" & md "%TEMP%" >nul 2>&1
del /f /s /q "%userprofile%\Local Settings\Temporary Internet Files\*.*" >nul 2>&1
del /f /s /q "%userprofile%\Local Settings\Temp\*.*" >nul 2>&1
del /f /s /q "%LOCALAPPDATA%\Temp\*.*" >nul 2>&1
del /f /s /q "%LOCALAPPDATA%\Microsoft\Windows\INetCache\*.*" >nul 2>&1
echo [5/8] 正在清理缩略图缓存和最近打开记录...
del /f /s /q /a "%LOCALAPPDATA%\Microsoft\Windows\Explorer\thumbcache_*.db" >nul 2>&1
del /f /q "%APPDATA%\Microsoft\Windows\Recent\*.*" >nul 2>&1
del /f /q "%userprofile%\recent\*.*" >nul 2>&1
echo [6/8] 正在清理 Cookies 和 错误报告/崩溃转储...
del /f /q "%userprofile%\cookies\*.*" >nul 2>&1
rd /s /q "%LOCALAPPDATA%\Microsoft\Windows\WER" >nul 2>&1
rd /s /q "%LOCALAPPDATA%\CrashDumps" >nul 2>&1
del /f /q %systemdrive%\MEMORY.DMP >nul 2>&1
echo [7/8] 正在清理 谷歌 Chrome 和 Edge 浏览器缓存...
for /d %%i in ("%LOCALAPPDATA%\Google\Chrome\User Data\*") do (
if exist "%%i\Cache" rd /s /q "%%i\Cache" >nul 2>&1
if exist "%%i\Code Cache" rd /s /q "%%i\Code Cache" >nul 2>&1
)
for /d %%i in ("%LOCALAPPDATA%\Microsoft\Edge\User Data\*") do (
if exist "%%i\Cache" rd /s /q "%%i\Cache" >nul 2>&1
if exist "%%i\Code Cache" rd /s /q "%%i\Code Cache" >nul 2>&1
)
echo [8/8] 正在清理 火狐 Firefox 浏览器缓存...
for /d %%i in ("%LOCALAPPDATA%\Mozilla\Firefox\Profiles\*") do (
if exist "%%i\cache2" rd /s /q "%%i\cache2" >nul 2>&1
if exist "%%i\startupCache" rd /s /q "%%i\startupCache" >nul 2>&1
)
echo.
echo 正在刷新网络 DNS 缓存...
ipconfig /flushdns >nul 2>&1
echo.
echo =========================================================================
echo 全 部 清 理 完 成!
echo =========================================================================
echo 提示:
echo 1. 浏览器缓存已彻底清空,首次打开网页时加载可能会稍慢,之后恢复正常。
echo 2. 您的浏览器书签、保存的密码、历史记录均安全保留,未被删除。
echo 3. 建议清理后重启一次电脑。
echo =========================================================================
echo.
pause
网络相关 2025-08-25 16:55:20 通过 网页 浏览(31)
共有 0 条评论!