计算机Dos批处理,编写一键清理系统垃圾的bat代码,编写自己清理系统的代码,就是这样简单。关于代码怎么使用: 【新建文本文件(记事本)】—【复制代码】—【粘贴代码】—【重命名文本文件后缀名为bat】,如下图: 运行效果: 选择2,不清理系统垃圾时: 选择1,清理系统垃圾时: del 命令的参数 /F 强制删除只读文件。 /S 从所有子目录删除指定文件。 /Q 安静模式。删除全局通配符时,不要求确认。 rd 命令的参数 /s 除目录本身外,还将删除指定目录下的所有子目录和文件。用于删除目录树。 /q 安静模式 /s 删除目录树时不要求确认。 代码: @echo off & title 清理系统垃圾 mode con lines=30 cols=60 %1 mshta vbscript:CreateObject('Shell.Application').ShellExecute('cmd.exe','/c %~s0 ::','','runas',1)(window.close)&&exit cd /d '%~dp0' :main cls color 2f echo. echo.----------------------------------------------------------- echo.请选择使用: echo. echo. 1.清理系统垃圾(即在下面输入1) echo. echo. 2.不清理系统垃圾(即在下面输入2) echo.----------------------------------------------------------- if exist '%SystemRoot%\System32\choice.exe' goto Win7Choice set /p choice=请输入数字并按回车键确认: echo. if %choice%==1 goto delmain if %choice%==2 goto end cls 'set choice=' echo 您输入有误,请重新选择。 ping 127.0.1 -n '2'>nul goto main :Win7Choice choice /c 12 /n /m '请输入相应数字:' if errorlevel 2 goto end if errorlevel 1 goto delmain cls goto main :delmain cls color 2f del /f /s /q %systemdrive%\*.tmp del /f /s /q %systemdrive%\*.mp3 del /f /s /q %systemdrive%\recycled\*.* del /f /s /q %windir%\*.bak del /f /s /q %windir%\prefetch\*.* rd /s /q %windir%\temp & md %windir%\temp del /f /q %userprofile%\cookies\*.* del /f /s /q 'C:\Documents and Settings\Administrator\Local Settings\History' del /f /s /q 'C:\Documents and Settings\Administrator\Local Settings\Temporary Internet Files' del /f /s /q 'C:\Documents and Settings\Administrator\Local Settings\Temp' del /f /s /q 'C:\Documents and Settings\Administrator\Local Settings\Temp\_xl7vss_' del /f /s /q 'D:\Program Files\QvodPlayer\Data' echo. goto end :end echo 请按任意键退出。 @Pause>nul 如果熟悉,可以自己修改核心代码,包含的地方越多,清理系统垃圾文件越多。 不过,为了误删你的文件,不懂得话,请不要随便添加代码。 |
|