[新手上路]批处理新手入门导读[视频教程]批处理基础视频教程[视频教程]VBS基础视频教程[批处理精品]批处理版照片整理器
[批处理精品]纯批处理备份&还原驱动[批处理精品]CMD命令50条不能说的秘密[在线下载]第三方命令行工具[在线帮助]VBScript / JScript 在线参考
返回列表 发帖

根据系统盘可用空间自动执行清理

系统空间暂定为5GB左右执行,由于本人技术不是那么好也只能这么编辑了,里边的数据自己去改,执行全部清理会调用系统盘的卸载程序,自行选择是否卸载(因为出于系统空间略小后加的卸载系统盘不必要的程序),打字很累直接上代码,没有加标注这些代码都是可以看懂的所以也没必要加入了,第二次在此论坛发帖多担待
如果觉得好点个赞,如果不好请坛友指正共同学习
  1. for /f "tokens=1,2 delims= " %%d in ('@wmic logicaldisk get deviceid^,freespace^|findstr/i "%systemdrive%"') do (
  2. set "disk=%%~ne"
  3. )
  4. set/a "disk=%disk:~0,-4%"
  5. set uninst_drive=lenovo Intel iastorIcon iastordatamgrsvc ati amd audio dolby realtek utility bluetooth management synaptics syntpenh
  6. set uninst_user=networx 8.12.11592.204 saying sidebar qqprotect qq\ qqgame\ opera ultraiso 7-zip winrar ikeeper sogouinput sogouwbinput fetion\ cbox kuwo \stormplayer\ adsafe formatfactory
  7. set ignore_system=%systemroot% wmpnetwk taskkill cmd wmic
  8. set ignore_drive=lenovo Intel iastorIcon iastordatamgrsvc ati amd audio dolby realtek utility bluetooth management synaptics syntpenh
  9. set ignore_user=%~dp0 networx 8.12.11592.204 saying sidebar qqprotect qq
  10. @if %disk% gtr 524288 (
  11. echo=执行常规清理
  12. @del/f/s/q "%systemdrive%\*2345*.*">nul 2>nul&@del/f/s/q "%systemdrive%\*baidu*.*">nul 2>nul&@del/f/s/q "%systemdrive%\*360*.*">nul 2>nul
  13. @del/f/s/q "%userprofile%\cookies\*.*">nul 2>nul
  14. @del/f/s/q "%userprofile%\local settings\history\*.*">nul 2>nul
  15. @del/f/s/q "%userprofile%\local settings\temp\*.*">nul 2>nul
  16. @del/f/s/q "%userprofile%\local settings\temporary internet files\*.*">nul 2>nul
  17. @del/f/s/q "%systemdrive%\*.tmp">nul 2>nul
  18. @del/f/s/q "%systemdrive%\*._mp">nul 2>nul
  19. @del/f/s/q "%systemdrive%\*.log">nul 2>nul
  20. @del/f/s/q "%systemdrive%\*.gid">nul 2>nul
  21. @del/f/s/q "%systemdrive%\*.chk">nul 2>nul
  22. @del/f/s/q "%systemdrive%\*.old">nul 2>nul
  23. @del/f/s/q "%systemdrive%\recycled\*.*">nul 2>nul
  24. @del/f/s/q "%systemroot%\*.bak">nul 2>nul
  25. @del/f/s/q "%systemroot%\prefetch\*.*">nul 2>nul
  26. @del/f/s/q "%userprofile%\cookies\*.*">nul 2>nul
  27. @del/f/s/q "%userprofile%\recent\*.*">nul 2>nul
  28. @del/f/s/q "%userprofile%\Local Settings\Temporary Internet Files\*.*">nul 2>nul
  29. @del/f/s/q "%userprofile%\Local Settings\Temp\*.*">nul 2>nul
  30. @del/f/s/q "%userprofile%\recent\*.*">nul 2>nul
  31. @del/f/s/q "%userprofile%\appdata\local\microsoft\internet explorer\domstore\*.xml">nul 2>nul
  32. @del/f/s/q "%userprofile%\appdata\local\microsoft\internet explorer\domstore\*.*">nul 2>nul
  33. @del/f/s/q "%userprofile%\appdata\roaming\microsoft\internet explorer\userdata\*.xml">nul 2>nul
  34. @del/f/s/q "%userprofile%\appdata\roaming\microsoft\internet explorer\userdata\*.*">nul 2>nul
  35. @rd/s/q "%systemroot%\temp">nul 2>nul@md "%systemroot%\temp">nul 2>nul
  36. @rd /s /q "%userprofile%\appdata\local\microsoft\internet explorer\domstore">nul 2>nul&&@md "%userprofile%\appdata\local\microsoft\internet explorer\domstore">nul 2>nul
  37. @rd /s /q "%userprofile%\appdata\roaming\microsoft\internet explorer\userdata">nul 2>nul&&@md "%userprofile%\appdata\roaming\microsoft\internet explorer\userdata">nul 2>nul
  38. ) else (
  39. echo=执行全部清理
  40. for /f "delims=" %%i in ('@wmic process get executablepath^,processid^|findstr/i "\ .exe"^|findstr/i/v "%ignore_system% %ignore_drive% %ignore_user%"') do (
  41.   for /f "tokens=2 delims=." %%j in ('echo=%%~nxi^|findstr "[0-9]"') do (
  42.    for /f "tokens=2 delims= " %%k in ('echo=%%j^|findstr "[0-9]"') do (
  43.     @wmic process get processid^|findstr "%%k">nul 2>nul&&@wmic process where processid=%%k call terminate>nul 2>nul
  44.     @tasklist|findstr "%%k">nul 2>nul&&@taskkill /f /t /pid "%%k">nul 2>nul)
  45. ))
  46. @del/f/s/q "%systemdrive%\*2345*.*">nul 2>nul&@del/f/s/q "%systemdrive%\*baidu*.*">nul 2>nul&@del/f/s/q "%systemdrive%\*360*.*">nul 2>nul
  47. @del/f/s/q "%userprofile%\cookies\*.*">nul 2>nul
  48. @del/f/s/q "%userprofile%\local settings\history\*.*">nul 2>nul
  49. @del/f/s/q "%userprofile%\local settings\temp\*.*">nul 2>nul
  50. @del/f/s/q "%userprofile%\local settings\temporary internet files\*.*">nul 2>nul
  51. @del/f/s/q "%systemdrive%\*.tmp">nul 2>nul
  52. @del/f/s/q "%systemdrive%\*._mp">nul 2>nul
  53. @del/f/s/q "%systemdrive%\*.log">nul 2>nul
  54. @del/f/s/q "%systemdrive%\*.gid">nul 2>nul
  55. @del/f/s/q "%systemdrive%\*.chk">nul 2>nul
  56. @del/f/s/q "%systemdrive%\*.old">nul 2>nul
  57. @del/f/s/q "%systemdrive%\recycled\*.*">nul 2>nul
  58. @del/f/s/q "%systemroot%\*.bak">nul 2>nul
  59. @del/f/s/q "%systemroot%\prefetch\*.*">nul 2>nul
  60. @del/f/s/q "%userprofile%\cookies\*.*">nul 2>nul
  61. @del/f/s/q "%userprofile%\recent\*.*">nul 2>nul
  62. @del/f/s/q "%userprofile%\Local Settings\Temporary Internet Files\*.*">nul 2>nul
  63. @del/f/s/q "%userprofile%\Local Settings\Temp\*.*">nul 2>nul
  64. @del/f/s/q "%userprofile%\recent\*.*">nul 2>nul
  65. @del/f/s/q "%userprofile%\appdata\local\microsoft\internet explorer\domstore\*.xml">nul 2>nul
  66. @del/f/s/q "%userprofile%\appdata\local\microsoft\internet explorer\domstore\*.*">nul 2>nul
  67. @del/f/s/q "%userprofile%\appdata\roaming\microsoft\internet explorer\userdata\*.xml">nul 2>nul
  68. @del/f/s/q "%userprofile%\appdata\roaming\microsoft\internet explorer\userdata\*.*">nul 2>nul
  69. @rd/s/q "%systemroot%\temp">nul 2>nul@md "%systemroot%\temp">nul 2>nul
  70. @rd /s /q "%userprofile%\appdata\local\microsoft\internet explorer\domstore">nul 2>nul&&@md "%userprofile%\appdata\local\microsoft\internet explorer\domstore">nul 2>nul
  71. @rd /s /q "%userprofile%\appdata\roaming\microsoft\internet explorer\userdata">nul 2>nul&&@md "%userprofile%\appdata\roaming\microsoft\internet explorer\userdata">nul 2>nul
  72. @start/i "" "%systemdrive%\windows\system32\cleanmgr.exe" /sagerun:99
  73. for /f "delims=" %%i in ('@dir/ad/s/b/l/on "%systemdrive%\"^|findstr/i "download S-1-5-21-3387676749-2585358728-169611052-500 temp"') do (@del/f/s/q "%%i\*.*">nul 2>nul)
  74. for /f "delims=" %%i in ('@dir/a-d/s/b/l/on "%systemdrive%\*unin*.exe"^|findstr/i "unin"^|findstr/i/v "%uninst_user%"') do (@start/i "" "%%i">nul 2>nul)
  75. )
复制代码

返回列表