Board logo

标题: [20090123更新]自写的最新版一键清理系统垃圾批处理 [打印本页]

作者: ynkmff     时间: 2010-1-23 07:17    标题: [20090123更新]自写的最新版一键清理系统垃圾批处理

参考坛里部分资料,
欢迎有兴趣的朋友斧正,交流
共同提高

----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

更新日志:20090123


@echo off & title 【一键清理WINXP垃圾】VERSION:1.0 DATE:20100121 & color 1f

if exist %windir%\TEMP\ClearBD.txt goto :start
echo.&echo (注:首次使用时,请在弹出窗口中选择要清理的项目,并点击确定)
cleanmgr /sageset:99

:start
echo.&echo.&echo.&echo 1、加强磁盘清理中,请稍侯......
cleanmgr /sagerun:99

echo.&echo.&echo.&echo 2、清理当前用户TEMP文件夹,请稍侯......
del /f /s /q "%temp%\*.*"
for /f %%i in ('dir /ad /b %temp%\') do rd /s /q "%temp%\%%i"

echo.&echo.&echo.&echo 3、清理系统TEMP文件夹,请稍侯......
del /f /s /q %windir%\TEMP\*.*
for /f %%i in ('dir /ad /b %windir%\TEMP\') do rd /s /q "%windir%\TEMP\%%i"

echo.&echo.&echo.&echo 4、清理(bak;bmp;old;tmp;_mp;gid;chk;syd;dir;dmp;nch;sqm;user.dmp),请稍侯......
del /f /s /q "%systemdrive%\*.bak"
del /f /s /q "%systemdrive%\*.old"
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%\*.syd"
del /f /s /q "%systemdrive%\*.dir"
del /f /s /q "%systemdrive%\*.dmp"
del /f /s /q "%systemdrive%\*.nch"
del /f /s /q "%systemdrive%\*.sqm"
del /f /s /q "%ALLUSERSPROFILE%\user.dmp"
del /f /s /q "%USERPROFILE%\user.dmp"
del /f /q "%windir%\*.bmp"
del /f /q "%windir%\clock.avi"
del /f /q "%windir%\control.ini"

echo.&echo.&echo.&echo 5、清理Windows文件夹已安装过的补丁,请稍侯......
for /f %%i in ('dir /ad /b %windir%\$*$') do (rd /S /Q "%windir%\%%i")
rd /s /q %windir%\ServicePackFiles
if not exist %windir%\ServicePackFiles md %windir%\ServicePackFiles

echo.&echo.&echo.&echo 6、清理Windows\inf里无用的驱动预编译文件,请稍侯......
del /f /q %windir%\inf\*.pnf

echo.&echo.&echo.&echo 7、清理Windows\System32\ReinstallBackups里冗余驱动程序备份,请稍侯......
rd /s /q %windir%\system32\ReinstallBackups
if not exist %windir%\system32\ReinstallBackups md %windir%\system32\ReinstallBackups

echo.&echo.&echo.&echo 8、清理WINDOWS\Driver Cache\i386冗余驱动程序备份文件,请稍侯......
del /f /q "%windir%\Driver Cache\i386\*.cab"

echo.&echo.&echo.&echo 9、清理IE缓存(cookies除外),历史记录,最近浏览文件,请稍侯......
for /f "tokens=1,2,* " %%i in ('REG QUERY "HKCU\software\Microsoft\Windows\CurrentVersion\Explorer\Shell Folders" ^| find /i "Cache"') do set "cache=%%k"
rd /s /q "%cache%" & if not exist "%cache%" md "%cache%"
for /f "tokens=1,2,* " %%i in ('REG QUERY "HKCU\software\Microsoft\Windows\CurrentVersion\Explorer\Shell Folders" ^| find /i "History"') do set "history=%%k"
rd /s /q "%history%" & if not exist "%history%" md "%history%"
for /f "tokens=1,2,* " %%i in ('REG QUERY "HKCU\software\Microsoft\Windows\CurrentVersion\Explorer\Shell Folders" ^| find /i "Recent"') do set "recent=%%k"
rd /s /q "%recent%" & if not exist "%recent%" md "%recent%"

echo.&echo.&echo.&echo 10、清理升级下载目录,请稍侯......
rd /s /q "%windir%\SoftwareDistribution\Download"
if not exist "%windir%\SoftwareDistribution\Download" md "%windir%\SoftwareDistribution\Download"

echo.&echo.&echo.&echo 11、、清理QQ2008垃圾,请稍侯......
for /f "tokens=1,2,* " %%i in ('REG QUERY "HKEY_LOCAL_MACHINE\SOFTWARE\TENCENT\QQ" ^| find /i "Install"') do set "QQPath=%%k"
dir /ad /b "%qqpath%"|findstr "^*$" > %windir%\TEMP\ClearBD.txt
for /f %%i in (%windir%\TEMP\ClearBD.txt) do rd /s /q "%qqpath%"%%i

echo.&echo.&echo.&echo 清理完毕!
echo.&echo.&echo.
pause


----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------


@echo off & title 【一键清理WINXP垃圾】VERSION:1.0 DATE:20100121 & color 1f

if exist %windir%\TEMP\ClearBD.txt goto :start
echo.&echo (注:首次使用时,请在弹出窗口中选择要清理的项目,并点击确定)
cleanmgr /sageset:99

:start
echo.&echo.&echo.&echo 1、加强磁盘清理中,请稍侯......
cleanmgr /sagerun:99

echo.&echo.&echo.&echo 2、清理当前用户TEMP文件夹,请稍侯......
del /f /s /q "%temp%\*.*"
dir /ad /b %temp%\ > %windir%\TEMP\ClearBD.txt
for /f %%i in (%windir%\TEMP\ClearBD.txt) do rd /s /q "%temp%\%%i"

echo.&echo.&echo.&echo 3、清理系统TEMP文件夹,请稍侯......
del /f /s /q %windir%\TEMP\*.*
dir /ad /b %windir%\TEMP\ > %temp%\ClearBD.txt
for /f %%i in (%temp%\ClearBD.txt) do rd /s /q "%windir%\TEMP\%%i"
del /f /s /q "%temp%\ClearBD.txt"

echo.&echo.&echo.&echo 4、清理(bak;bmp;old;tmp;_mp;gid;chk;syd;dir;dmp;nch;sqm;user.dmp),请稍侯......
del /f /s /q "%systemdrive%\*.bak"
del /f /s /q "%systemdrive%\*.old"
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%\*.syd"
del /f /s /q "%systemdrive%\*.dir"
del /f /s /q "%systemdrive%\*.dmp"
del /f /s /q "%systemdrive%\*.nch"
del /f /s /q "%systemdrive%\*.sqm"
del /f /s /q "%ALLUSERSPROFILE%\user.dmp"
del /f /s /q "%USERPROFILE%\user.dmp"
del /f /q "%windir%\*.bmp"
del /f /q "%windir%\clock.avi"
del /f /q "%windir%\control.ini"

echo.&echo.&echo.&echo 5、清理Windows文件夹已安装过的补丁,请稍侯......
dir /ad /b %windir%\$*$ > %windir%\TEMP\ClearBD.txt
for /f %%i in (%windir%\TEMP\ClearBD.txt) do (rd /S /Q "%windir%\%%i")
rd /s /q %windir%\ServicePackFiles
if not exist %windir%\ServicePackFiles md %windir%\ServicePackFiles

echo.&echo.&echo.&echo 6、清理Windows\inf里无用的驱动预编译文件,请稍侯......
del /f /q %windir%\inf\*.pnf

echo.&echo.&echo.&echo 7、清理Windows\System32\ReinstallBackups里冗余驱动程序备份,请稍侯......
rd /s /q %windir%\system32\ReinstallBackups
if not exist %windir%\system32\ReinstallBackups md %windir%\system32\ReinstallBackups

echo.&echo.&echo.&echo 8、清理WINDOWS\Driver Cache\i386冗余驱动程序备份文件,请稍侯......
del /f /q "%windir%\Driver Cache\i386\*.cab"

echo.&echo.&echo.&echo 9、清理IE缓存(cookies除外),请稍侯......
rd /s /q "%USERPROFILE%\Local Settings\Temporary Internet Files"
if not exist "%USERPROFILE%\Local Settings\Temporary Internet Files" md "%USERPROFILE%\Local Settings\Temporary Internet Files"

echo.&echo.&echo.&echo 10、清理历史记录,请稍侯......
rd /s /q "%USERPROFILE%\Local Settings\History"
if not exist "%USERPROFILE%\Local Settings\History" md "%USERPROFILE%\Local Settings\History"

echo.&echo.&echo.&echo 11、清理最近浏览文件的快捷方式记录,请稍侯......
rd /s /q "%USERPROFILE%\Recent"
if not exist "%USERPROFILE%\Recent" md "%USERPROFILE%\Recent"

echo.&echo.&echo.&echo 12、清理升级下载目录,请稍侯......
rd /s /q "%windir%\SoftwareDistribution\Download"
if not exist "%windir%\SoftwareDistribution\Download" md "%windir%\SoftwareDistribution\Download"

echo.&echo.&echo.&echo 13、清理"Windows 文件保护"文件高速缓存,请稍侯......
sfc.exe /purgecache
rd /s /q %windir%\system32\dllcache
if not exist %windir%\system32\dllcache md %windir%\system32\dllcache

echo.&echo.&echo.&echo 14、清理QQ垃圾,请稍侯......
for /f "tokens=1,2,* " %%i in ('REG QUERY "HKEY_LOCAL_MACHINE\SOFTWARE\TENCENT\QQ" ^| find /i "Install"') do set "QQPath=%%k"
dir /ad /b "%qqpath%"|findstr "^*$" > %windir%\TEMP\ClearBD.txt
for /f %%i in (%windir%\TEMP\ClearBD.txt) do rd /s /q "%qqpath%"%%i

echo.&echo.&echo.&echo 清理完毕!
echo.&echo.&echo.
pause



Last edited by ynkmff on 2010-1-23 at 22:40 ]

作者: ynkmff     时间: 2010-1-23 07:19
占楼备用,
如果有误,欢迎斧正
如果有议,欢迎交流


部分仅供参考,偷懒写的


echo.&echo.&echo.&echo 15、清理360卫士下载系统补丁、软件,请稍侯......
del /f /q "D:\Program Files\360\360safe\hotfix\*.*"
del /f /q "D:\Program Files\360\360safe\SoftMgr\download\*.*"

echo.&echo.&echo.&echo 16、清理QQLIVE、迅雷看看缓存,请稍侯......
rd /s /q "D:\QQVideo.Cache\vodcache"
if not exist "D:\QQVideo.Cache\vodcache" md "D:\QQVideo.Cache\vodcache"
rd /s /q "D:\kankan\VODCache"
if not exist "D:\kankan\VODCache" md "D:\kankan\VODCache"



Last edited by ynkmff on 2010-1-23 at 07:22 ]

作者: slore     时间: 2010-1-23 16:23
dir /ad /b %temp%\ > %windir%\TEMP\ClearBD.txt
for /f %%i in (%windir%\TEMP\ClearBD.txt) do rd /s /q "%temp%\%%i"
del /f /s /q "%temp%\ClearBD.txt"


for /f %%i in ('dir /ad /b %temp%\') do rd /s /q "%temp%\%%i"


3句可以用一句。。。

IE的临时文件夹。。。位置不固定。。。

13、清理"Windows 文件保护"文件高速缓存,请稍侯......
这个人人都要删除么?现在硬盘那么大,这个留着吧,这个算垃圾?

作者: HAT     时间: 2010-1-23 16:58
QQ2009的注册表项名称跟以前的版本略有不同

作者: ynkmff     时间: 2010-1-23 20:48
Originally posted by slore at 2010-1-23 16:23:
dir /ad /b %temp%\ > %windir%\TEMP\ClearBD.txt
for /f %%i in (%windir%\TEMP\ClearBD.txt) do rd /s /q "%temp%\%%i"
del /f /s /q "%temp%\ClearBD.txt"


for /f %%i in ('dir ...


谢谢指点,已修改,更新,请再指点

作者: ynkmff     时间: 2010-1-23 20:51
Originally posted by HAT at 2010-1-23 16:58:
QQ2009的注册表项名称跟以前的版本略有不同


是多少了?

不过,我记得,QQ2009自带垃圾清理器,所以不需要了,呵呵

作者: slore     时间: 2010-1-24 01:03
del /f /s /q "%temp%\*.*"
for /f %%i in ('dir /ad /b %temp%\') do rd /s /q "%temp%\%%i"


del的/s就不要了。

作者: ynkmff     时间: 2010-1-24 13:41
Originally posted by slore at 2010-1-24 01:03:
del /f /s /q "%temp%\*.*"
for /f %%i in ('dir /ad /b %temp%\') do rd /s /q "%temp%\%%i"


del的/s就不要了。


呵呵,兄台好眼力,这个/s,确实多余了

作者: slore     时间: 2010-1-24 13:45
/s 的话,先删除慢。。。

后面会连文件夹一起删除,所以前面不用遍历子目录删除文件。