电脑使用久了,系统或者软件就会产生大量的日志文件、临时文件等垃圾文件。这些垃圾文件日积月累,不仅会大量占用磁盘空间,也会严重拖慢系统运行速度。
所以定时清理垃圾文件十分有必要。我们可以手动删除,也可以借助本文提供的批处理自动删除。

1,创建一个清除垃圾的.bat文件
(1)在桌面上单击鼠标右键,选择“新建”选择“文本文档”
(2)将新建的文件改名为“垃圾文件清除.bat”(注意 .txt 后缀要记得删掉)
(3)右击该文件,选择“编辑”。在文件中输入如下内容(两个版本任选其一):
这个是下面是最新完美版(会打印出删除的文件):
@echo off
echo 正在清除系统垃圾文件,请稍等......
del /f /s /q %systemdrive%\\*.tmp
del /f /s /q %systemdrive%\\*._mp
del /f /s /q %systemdrive%\\*.gid
del /f /s /q %systemdrive%\\*.chk
del /f /s /q %systemdrive%\\*.old
del /f /s /q %windir%\\*.bak
del /f /s /q %windir%\\temp\\*.*
del /f /a /q %systemdrive%\\*.sqm
del /f /s /q %windir%\\SoftwareDistribution\\Download\\*.*
del /f /s /q "%userprofile%\\cookies\\*.*"
del /f /s /q "%userprofile%\\recent\\*.*"
del /f /s /q "%userprofile%\\local settings\\temporary internet files\\*.*"
del /f /s /q "%userprofile%\\local settings\\temp\\*.*"
echo 清除系统垃圾文件完成!
echo. & pause
下面是这个是修改版(但删除的文件不会打印出来):@echo off
echo.
echo 正在安全地自动清除垃圾文件……
del /f /q %systemdrive%\\*.tmp>nul 2>nul
del /f /q %systemdrive%\\*._mp>nul 2>nul
del /f /q %systemdrive%\\*.log>nul 2>nul
del /f /q %systemdrive%\\*.gid>nul 2>nul
del /f /q %systemdrive%\\*.chk>nul 2>nul
del /f /q %systemdrive%\\*.old>nul 2>nul
del /f /q %windir%\\*.bak>nul 2>nul
del /f /q %windir%\\*.tmp>nul 2>nul
del /f /q %windir%\\prefetch\\*.*>nul 2>nul
del /f /s /q %systemdrive%\\recycled\\*.*
del /f /q "%ALLUSERSPROFILE%\\Documents\\DrWatson\\*.*">nul 2>nul
del /f /q "%USERPROFILE%\\Cookies\\*.txt">nul 2>nul
del /f /q /s "%TEMP%\\*.*">nul 2>nul
del /f /q /s "%Systemroot%\\Prefetch\\*.*">nul 2>nul
del /f /q "%USERPROFILE%\\Recent\\*.*">nul 2>nul
del /f /q "%USERPROFILE%\\Application Data\\Microsoft\\Office\\Recent\\*.lnk">nul 2>nul
del /f /q /s "%USERPROFILE%\\Local Settings\\Temp\\*.*">nul 2>nul
rd /s /q %windir%\\temp & md %windir%\\temp>nul 2>nul
if not exist %SystemRoot%\\Minidump\\NUL del /f /q /s %SystemRoot%\\Minidump\\*.*>nul 2>nul
del /f /s /q "%userprofile%\\Local Settings\\Temporary Internet Files\\*.*">nul 2>nul
echo 清除系统LJ完成!
echo. & pause
原文出自:www.hangge.com 转载请保留原文链接:https://www.hangge.com/blog/cache/detail_1652.html