rendered paste body@echo off
rem ******************************************************************
rem * *
rem * DELFILES.BAT *
rem * Deletes the temporary internet files (IE cache and cookies), *
rem * temporary directory (%USER%\local settings\temp)", the *
rem * prefetch and all recycle bins found on C: *
rem * *
rem ******************************************************************
rem Copyright© Kenneth Voort. All rights reserved.
rem **********************************
rem * Parse the command line options *
rem **********************************
set command=dryrun
set quiet=
:parseagain
if x==%1x goto doneparsing
if %1==del set command=del
if %1==quiet set quiet=/q
shift
goto parseagain
:doneparsing
echo command is %command%
echo quiet is %quiet%
rem **************************
rem * Loop through each user *
rem **************************
pushd "\documents and settings"
for /F "delims=" %%u in ('dir /b /a') do call :delete "%%u"
popd
if "%command%" == "del" (
del c:\windows\prefetch\*.* %quiet%
) else (
dir c:\windows\prefetch
)
rem *************************************
rem * Now we empty all the recycle bins *
rem * Recycle bins are named after the *
rem * volume they recycle for, by dir *
rem *************************************
pushd c:\recycler
echo Now in recycler...
for /F %%r in ('dir /a/b') do (
pushd %%r
if "%command%" == "del" (
del *.* %quiet%
) else (
dir
)
popd
)
popd
echo "Command was %command%"
goto end
:delete
pushd "c:\documents and settings\%1"
if /i not "%quiet%"=="/q" echo Deleting files for %1...
rem ****************************************************************
rem * Delete the temporary Internet files, also known as the cache *
rem * cookies get deleted too *
rem ****************************************************************
if exist "local settings\temporary internet files" (
if "%command%" == "del" (
if exist "localsettings\temporary internet files\*.*" del "local settings\temporary internet files\*.*" %quiet%
) else (
dir
)
) else (
echo no temporary internet files direcrory found for %1
)
rem ******************************
rem * Delete the user's temp dir *
rem ******************************
if exist "local settings\temp" (
if "%command%" == "del" (
del "local settings\temp\*.*" %quiet%
) else (
dir
)
) else (
echo Temp dir for %1 not found
)
rem ********************************************************
rem * Delete the mozilla firefox cache *
rem * Mozilla gives its profile directories a random name, *
rem * so we need to loop through a FOR command to be sure *
rem * we get it, and so that we get any other profiles *
rem * the user may use *
rem ********************************************************
if exist "local settings\application data\moZilla\firefox" (
pushd "local settings\application data\mozilla\firefox\profiles
for /F %%p in ('dir /b /a') do (
pushd %%p\cache
if "%command%" == "del" (
del *.* %quiet%
) else (
dir
)
popd
)
popd
)
popd
goto end
:end