計(jì)算機(jī)Dos批處理,編寫一鍵清理系統(tǒng)垃圾的bat代碼,編寫自己清理系統(tǒng)的代碼,就是這樣簡(jiǎn)單。關(guān)于代碼怎么使用: 【新建文本文件(記事本)】—【復(fù)制代碼】—【粘貼代碼】—【重命名文本文件后綴名為bat】,如下圖: 運(yùn)行效果: 選擇2,不清理系統(tǒng)垃圾時(shí): 選擇1,清理系統(tǒng)垃圾時(shí): del 命令的參數(shù) /F 強(qiáng)制刪除只讀文件。 /S 從所有子目錄刪除指定文件。 /Q 安靜模式。刪除全局通配符時(shí),不要求確認(rèn)。 rd 命令的參數(shù) /s 除目錄本身外,還將刪除指定目錄下的所有子目錄和文件。用于刪除目錄樹(shù)。 /q 安靜模式 /s 刪除目錄樹(shù)時(shí)不要求確認(rèn)。 代碼: @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.請(qǐng)選擇使用: echo. echo. 1.清理系統(tǒng)垃圾(即在下面輸入1) echo. echo. 2.不清理系統(tǒng)垃圾(即在下面輸入2) echo.----------------------------------------------------------- if exist '%SystemRoot%\System32\choice.exe' goto Win7Choice set /p choice=請(qǐng)輸入數(shù)字并按回車鍵確認(rèn): echo. if %choice%==1 goto delmain if %choice%==2 goto end cls 'set choice=' echo 您輸入有誤,請(qǐng)重新選擇。 ping 127.0.1 -n '2'>nul goto main :Win7Choice choice /c 12 /n /m '請(qǐng)輸入相應(yīng)數(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 請(qǐng)按任意鍵退出。 @Pause>nul 如果熟悉,可以自己修改核心代碼,包含的地方越多,清理系統(tǒng)垃圾文件越多。 不過(guò),為了誤刪你的文件,不懂得話,請(qǐng)不要隨便添加代碼。 |
|
來(lái)自: 酒心1000 > 《1實(shí)用知識(shí)技巧》