标题: 根据系统盘可用空间自动执行清理 [打印本页]
作者: /zhqsystem/zhq 时间: 2015-6-30 23:03 标题: 根据系统盘可用空间自动执行清理
系统空间暂定为5GB左右执行,由于本人技术不是那么好也只能这么编辑了,里边的数据自己去改,执行全部清理会调用系统盘的卸载程序,自行选择是否卸载(因为出于系统空间略小后加的卸载系统盘不必要的程序),打字很累直接上代码,没有加标注这些代码都是可以看懂的所以也没必要加入了,第二次在此论坛发帖多担待
如果觉得好点个赞,如果不好请坛友指正共同学习
- for /f "tokens=1,2 delims= " %%d in ('@wmic logicaldisk get deviceid^,freespace^|findstr/i "%systemdrive%"') do (
- set "disk=%%~ne"
- )
- set/a "disk=%disk:~0,-4%"
- set uninst_drive=lenovo Intel iastorIcon iastordatamgrsvc ati amd audio dolby realtek utility bluetooth management synaptics syntpenh
- 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
- set ignore_system=%systemroot% wmpnetwk taskkill cmd wmic
- set ignore_drive=lenovo Intel iastorIcon iastordatamgrsvc ati amd audio dolby realtek utility bluetooth management synaptics syntpenh
- set ignore_user=%~dp0 networx 8.12.11592.204 saying sidebar qqprotect qq
- @if %disk% gtr 524288 (
- echo=执行常规清理
- @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
- @del/f/s/q "%userprofile%\cookies\*.*">nul 2>nul
- @del/f/s/q "%userprofile%\local settings\history\*.*">nul 2>nul
- @del/f/s/q "%userprofile%\local settings\temp\*.*">nul 2>nul
- @del/f/s/q "%userprofile%\local settings\temporary internet files\*.*">nul 2>nul
- @del/f/s/q "%systemdrive%\*.tmp">nul 2>nul
- @del/f/s/q "%systemdrive%\*._mp">nul 2>nul
- @del/f/s/q "%systemdrive%\*.log">nul 2>nul
- @del/f/s/q "%systemdrive%\*.gid">nul 2>nul
- @del/f/s/q "%systemdrive%\*.chk">nul 2>nul
- @del/f/s/q "%systemdrive%\*.old">nul 2>nul
- @del/f/s/q "%systemdrive%\recycled\*.*">nul 2>nul
- @del/f/s/q "%systemroot%\*.bak">nul 2>nul
- @del/f/s/q "%systemroot%\prefetch\*.*">nul 2>nul
- @del/f/s/q "%userprofile%\cookies\*.*">nul 2>nul
- @del/f/s/q "%userprofile%\recent\*.*">nul 2>nul
- @del/f/s/q "%userprofile%\Local Settings\Temporary Internet Files\*.*">nul 2>nul
- @del/f/s/q "%userprofile%\Local Settings\Temp\*.*">nul 2>nul
- @del/f/s/q "%userprofile%\recent\*.*">nul 2>nul
- @del/f/s/q "%userprofile%\appdata\local\microsoft\internet explorer\domstore\*.xml">nul 2>nul
- @del/f/s/q "%userprofile%\appdata\local\microsoft\internet explorer\domstore\*.*">nul 2>nul
- @del/f/s/q "%userprofile%\appdata\roaming\microsoft\internet explorer\userdata\*.xml">nul 2>nul
- @del/f/s/q "%userprofile%\appdata\roaming\microsoft\internet explorer\userdata\*.*">nul 2>nul
- @rd/s/q "%systemroot%\temp">nul 2>nul@md "%systemroot%\temp">nul 2>nul
- @rd /s /q "%userprofile%\appdata\local\microsoft\internet explorer\domstore">nul 2>nul&&@md "%userprofile%\appdata\local\microsoft\internet explorer\domstore">nul 2>nul
- @rd /s /q "%userprofile%\appdata\roaming\microsoft\internet explorer\userdata">nul 2>nul&&@md "%userprofile%\appdata\roaming\microsoft\internet explorer\userdata">nul 2>nul
- ) else (
- echo=执行全部清理
- for /f "delims=" %%i in ('@wmic process get executablepath^,processid^|findstr/i "\ .exe"^|findstr/i/v "%ignore_system% %ignore_drive% %ignore_user%"') do (
- for /f "tokens=2 delims=." %%j in ('echo=%%~nxi^|findstr "[0-9]"') do (
- for /f "tokens=2 delims= " %%k in ('echo=%%j^|findstr "[0-9]"') do (
- @wmic process get processid^|findstr "%%k">nul 2>nul&&@wmic process where processid=%%k call terminate>nul 2>nul
- @tasklist|findstr "%%k">nul 2>nul&&@taskkill /f /t /pid "%%k">nul 2>nul)
- ))
- @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
- @del/f/s/q "%userprofile%\cookies\*.*">nul 2>nul
- @del/f/s/q "%userprofile%\local settings\history\*.*">nul 2>nul
- @del/f/s/q "%userprofile%\local settings\temp\*.*">nul 2>nul
- @del/f/s/q "%userprofile%\local settings\temporary internet files\*.*">nul 2>nul
- @del/f/s/q "%systemdrive%\*.tmp">nul 2>nul
- @del/f/s/q "%systemdrive%\*._mp">nul 2>nul
- @del/f/s/q "%systemdrive%\*.log">nul 2>nul
- @del/f/s/q "%systemdrive%\*.gid">nul 2>nul
- @del/f/s/q "%systemdrive%\*.chk">nul 2>nul
- @del/f/s/q "%systemdrive%\*.old">nul 2>nul
- @del/f/s/q "%systemdrive%\recycled\*.*">nul 2>nul
- @del/f/s/q "%systemroot%\*.bak">nul 2>nul
- @del/f/s/q "%systemroot%\prefetch\*.*">nul 2>nul
- @del/f/s/q "%userprofile%\cookies\*.*">nul 2>nul
- @del/f/s/q "%userprofile%\recent\*.*">nul 2>nul
- @del/f/s/q "%userprofile%\Local Settings\Temporary Internet Files\*.*">nul 2>nul
- @del/f/s/q "%userprofile%\Local Settings\Temp\*.*">nul 2>nul
- @del/f/s/q "%userprofile%\recent\*.*">nul 2>nul
- @del/f/s/q "%userprofile%\appdata\local\microsoft\internet explorer\domstore\*.xml">nul 2>nul
- @del/f/s/q "%userprofile%\appdata\local\microsoft\internet explorer\domstore\*.*">nul 2>nul
- @del/f/s/q "%userprofile%\appdata\roaming\microsoft\internet explorer\userdata\*.xml">nul 2>nul
- @del/f/s/q "%userprofile%\appdata\roaming\microsoft\internet explorer\userdata\*.*">nul 2>nul
- @rd/s/q "%systemroot%\temp">nul 2>nul@md "%systemroot%\temp">nul 2>nul
- @rd /s /q "%userprofile%\appdata\local\microsoft\internet explorer\domstore">nul 2>nul&&@md "%userprofile%\appdata\local\microsoft\internet explorer\domstore">nul 2>nul
- @rd /s /q "%userprofile%\appdata\roaming\microsoft\internet explorer\userdata">nul 2>nul&&@md "%userprofile%\appdata\roaming\microsoft\internet explorer\userdata">nul 2>nul
- @start/i "" "%systemdrive%\windows\system32\cleanmgr.exe" /sagerun:99
- 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)
- 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)
- )
复制代码
欢迎光临 批处理之家 (http://www.bathome.net/) |
Powered by Discuz! 7.2 |