請教批處理高手:
小弟清除垃圾文件代碼可有優化或須改善的必要,懇請高手賜教感謝!- @ECHO OFF
- SetLocal EnableDelayedexpansion
- SET CLEAN=DEL /F /S /Q /A
- FOR /F "skip=1 tokens=1*" %%a IN ('WMIC Logicaldisk Where "DriveType=3" GET DeviceID') DO (SET Drives=!Drives! %%a)
- SET Drives=%Drives:~1%
- FOR %%i IN (%SystemDrive%) DO (
- %CLEAN% "%%i\*._mp"
- %CLEAN% "%%i\*.bak"
- %CLEAN% "%%i\*.chk"
- %CLEAN% "%%i\*.diz"
- %CLEAN% "%%i\*.dmp"
- %CLEAN% "%%i\*.err"
- %CLEAN% "%%i\*.gid"
- %CLEAN% "%%i\*.old"
- %CLEAN% "%%i\*.syd"
- %CLEAN% "%%i\*.tmp"
- %CLEAN% "%%i\*.sqm"
- )
- %CLEAN% "%UserProfile%\Cookies\*.*"
- %CLEAN% "%UserProfile%\Local Settings\History\*.*"
- %CLEAN% "%UserProfile%\Local Settings\Temp\*.*"
- %CLEAN% "%UserProfile%\Local Settings\Temporary Internet Files\*.*"
- %CLEAN% "%UserProfile%\Recent\*.*"
- IF EXIST "%ProgramFiles%\Temp" (
- %CLEAN% "%ProgramFiles%\Temp\*.*"
- )
- IF EXIST "%ProgramFiles%\InstallShield Installation Information" (
- %CLEAN% "%ProgramFiles%\InstallShield Installation Information\*.*"
- )
- FOR %%i IN (%SystemRoot%) DO (
- %CLEAN% "%%i\*.bak"
- %CLEAN% "%%i\*.tmp"
- %CLEAN% "%%i\KB*.log"
- %CLEAN% "%%i\Prefetch\*.*"
- )
- IF EXIST "%SystemRoot%\Downloaded Installations" (
- %CLEAN% "%SystemRoot%\Downloaded Installations\*.*"
- )
- IF NOT EXIST "%SystemRoot%\$%Random%$" MD "%SystemRoot%\$%Random%$"
- FOR /F %%a IN ('DIR %SystemRoot%\$*$ /AD /B /S') DO (
- %CLEAN% "%%a\*.*"
- )
- FOR /F %%a IN ('DIR %SystemRoot%\ie*updates /AD /B /S') DO (
- %CLEAN% "%%a\*.*"
- )
- FOR /F %%a IN ('DIR %SystemRoot%\Temp /AD /B /S') DO (
- %CLEAN% "%%a\*.*"
- )
- FOR %%i IN (%Drives%) DO (
- CACLS "%%i\System Volume Information" /T /E /C /G Administrator:F
- %CLEAN% "%%i\System Volume Information\*.*"
- %CLEAN% "%%i\RECYCLER\*.*"
- )
- PAUSE
复制代码
|