計算機Dos批處理,編寫一鍵清理系統(tǒng)垃圾的bat代碼,編寫自己清理系統(tǒng)的代碼,就是這樣簡單。關于代碼怎么使用: 【新建文本文件(記事本)】—【復制代碼】—【粘貼代碼】—【重命名文本文件后綴名為bat】,如下圖: 運行效果: 選擇2,不清理系統(tǒng)垃圾時: 選擇1,清理系統(tǒng)垃圾時: del 命令的參數(shù) /F 強制刪除只讀文件。 /S 從所有子目錄刪除指定文件。 /Q 安靜模式。刪除全局通配符時,不要求確認。 rd 命令的參數(shù) /s 除目錄本身外,還將刪除指定目錄下的所有子目錄和文件。用于刪除目錄樹。 /q 安靜模式 /s 刪除目錄樹時不要求確認。 代碼: @echo off & title 清理系統(tǒng)垃圾 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.清理系統(tǒng)垃圾(即在下面輸入1) echo. echo. 2.不清理系統(tǒng)垃圾(即在下面輸入2) echo.----------------------------------------------------------- if exist '%SystemRoot%\System32\choice.exe' goto Win7Choice set /p choice=請輸入數(shù)字并按回車鍵確認: 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 '請輸入相應數(shù)字:' 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 如果熟悉,可以自己修改核心代碼,包含的地方越多,清理系統(tǒng)垃圾文件越多。 不過,為了誤刪你的文件,不懂得話,請不要隨便添加代碼。 |
|
|