created script that deletes all temp and temporary internet files

Discussion in 'Off Topic Area' started by jroe52, Dec 1, 2009.

  1. jroe52

    jroe52 Valued Member

    this is a .cmd file, so copy and paste into notepad... save as "all types" then name it and end it in .cmd

    -cleans each user on the machine. atf and ccleaner only clean the current user account and a generic account all users. this script will help clean up machines with alot of users.

    it has cut my malwarebytes/spybot scan times by 25-50%.

    this version: winxp and win2k

    Code:
    @echo off
    title Cleanup utility - must use an admin account - %computername% (ver. 2009-11-19)
    rem for loop presented by HenrikS (piriform.com) and in Danish
    rem ===================================================================
    rem Cleans temp files, temporary, prefetch and java cache
    rem ===================================================================
    
    rem ===================================================================
    color 17
    rem set Lokal_sti=Lokale~1
    set Lokal_sti=Local Settings
    
    
    rem tjek sprog (engelsk?) via pause kommandoen
    echo a | pause | find "any key" >nul
    IF %errorlevel% EQU 0 set Lokal_sti=Locals~1
    
    echo Everyone's Temp Deleter- Force delete tempory files
    echo ===================================================================
    
    echo This program will clean up each individual's temporary files unlike ATF/Ccleaner
    echo Like ATF, this requires the admin account
    echo ===================================================================
    echo Cleans temp files, temporary internet files, prefetch, java cache 
    
    echo ***
    echo Press Enter to Continue *****  PRESS CTRL+C TO QUIT
    echo ***
    
    echo ******************************************
    echo Application will close when its complete!
    
    echo ******************************************
    pause
    cls
    echo ******************************************
    echo emptying  c:\windows\temp
    echo ******************************************
    
    echo  *** enter to continue *** CTRL+C to quit
    rem pause
    rd c:\windows\TEMP /s /q 
    md C:\windows\TEMP
    rd c:\TEMP /s /q 
    md C:\TEMP
    cls
    echo windows temp files cleaned
    rem pause
    cls
    
    echo ******************************************
    echo emptying c:\windows\prefetch
    echo ******************************************
    echo  *** enter to continue *** CTRL+C to quit
    rem pause
    rd c:\windows\Prefetch /s /q 
    md C:\windows\Prefetch
    cls
    echo windows prefetch folder cleaned
    rem pause
    cls
    rem echo ******************************************
    rem echo emptying recycling bin
    rem echo ******************************************
    rem deltree /y c:\recycled
    rem mkdir "c:\recycled"
    rem echo  *** enter to continue *** CTRL+C to quit
    rem pause
    
    
    ATTRIB %systemdrive%\RECYCLER\* -R -S -H /S /D
    DEL %systemdrive%\RECYCLER\* /F /S /Q 
    RD %systemdrive%\RECYCLER /S /Q 
    
    
    
    rem windows 7
    rem del c:\$Recycle.Bin\. /f /s /q /a
    rem echo windows prefetch folder cleaned
    rem pause
    rem cls
    echo ******************************************
    echo clearing temp cache files for every user
    echo ******************************************
    echo  *** enter to continue *** CTRL+C to quit
    rem pause
    
    for /d %%i in ("c:\documents and settings\*") do call :DelInet "%%i"
    
    goto :eof
    :DelInet
    
    rem test
    rem end test
    for /d %%j in ("%~1\Local Settings\Temporary Internet Files\Content.IE5\*") do call :DelTDir "%%j"
    del "%~1\Local Settings\Temporary Internet Files\Content.IE5\." /f /s /q /a
    
    rem end test
    for /d %%j in ("%~1\%Lokal_sti%\Temporary Internet Files\Content.IE5\*") do call :DelTDir "%%j"
    del "%~1\%Lokal_sti%\Temporary Internet Files\Content.IE5\." /f /s /q /a
    del "%~1\%Lokal_sti%\Temporary Internet Files\Content.IE5\*.*" /f /s /q /a
    rem echo ie temporary internet files cleaned
    
    for /d %%j in ("%~1\%Lokal_sti%\Temp\*") do call :DelTdir "%%j"
    del "%~1\%Lokal_sti%\Temp\." /q /a
    
    rem echo local user temp files cleaned
    for /d %%j in ("%~1\%Lokal_sti%\Temporary Internet Files\*") do call :DelTDir "%%j"
    del "%~1\%Lokal_sti%\Temporary Internet Files\." /F /S /Q /A
    del "%~1\%Lokal_sti%\Temporary Internet Files\*.*" /F /S /Q /A
    
    for /d %%j in ("%~1\%Lokal_sti%\Temporary Internet Files\*") do call :DelTDir "%%j"
    del /F /S /Q /A "%~1\%Lokal_sti%\Temporary Internet Files\*.*" 
    
    rem echo local user temp files cleaned
    for /d %%j in ("%~1\Local Settings\Temporary Internet Files\*") do call :DelTDir "%%j"
    del "%~1\Local Settings\Temporary Internet Files\." /F /S /Q /A
    del "%~1\Local Settings\Temporary Internet Files\*.*" /F /S /Q /A
    
    for /d %%j in ("%~1\%Lokal_sti%\Temporary Internet Files\*") do call :DelTDir "%%j"
    del "%~1\%Lokal_sti%\Temporary Internet Files\." /q /a
    del "%~1\%Lokal_sti%\Temporary Internet Files\*.*" /f /s /q
    
    for /d %%j in ("%~1\%Lokal_sti%\Temporary Internet Files\Content.IE5\*") do call :DelTDir "%%j"
    del "%~1\%Lokal_sti%\Temporary Internet Files\Content.IE5\." /F /S /Q
    del "%~1\%Lokal_sti%\Temporary Internet Files\Content.IE5\*.*" /F /S /Q
    
    rem remove all temp files by force
    for /d %%j in ("%~1\%Lokal_sti%\Temp\Temporary Internet Files\*") do call :DelTDir "%%j"
    del "%~1\%Lokal_sti%\Temp\Temporary Internet Files\." /f /s /q
    del "%~1\%Lokal_sti%\Temp\Temporary Internet Files\." /q /a
    
    for /d %%j in ("%~1\%Lokal_sti%\Temp\Temporary Internet Files\Content.IE5\*") do call :DelTDir "%%j"
    del "%~1\%Lokal_sti%\Temp\Temporary Internet Files\Content.IE5\." /F /S /Q /A
    del "%~1\%Lokal_sti%\Temp\Temporary Internet Files\Content.IE5\*.*" /F /S /Q /A
    
    
    rmdir "%~1\%Lokal_sti%\Temp\Temporary Internet Files\Content.IE5\" /S /Q
    md "%~1\%Lokal_sti%\Temp\Temporary Internet Files\Content.IE5"
    
    
    rmdir "%~1\%Lokal_sti%\Temporary Internet Files\Content.IE5\" /S /Q
    md "%~1\%Lokal_sti%\Temporary Internet Files\Content.IE5"
    
    
    rmdir "%~1\%Lokal_sti%\Temp\Temporary Internet Files\" /S /Q
    md "%~1\%Lokal_sti%\Temp\Temporary Internet Files"
    
    rmdir "%~1\%Lokal_sti%\Temporary Internet Files\" /S /Q
    md "%~1\%Lokal_sti%\Temporary Internet Files"
    
    
    
    cls
    echo every user's temporary internet files and temp folders cleaned, windows temp/prefetch also cleaned
    
    cls
    
    echo *************************
    echo clearing Every user's java cache folder
    echo *************************
    
    echo  *** enter to continue *** CTRL+C to quit
    for /d %%j in ("%~1\Application Data\Sun\Java\Deployment\javaws\cache\*") do call :DelTDir "%%j"
    del "%~1\Application Data\Sun\Java\Deployment\javaws\cache\." /f /s /q /a
    for /d %%j in ("%~1\Application Data\Sun\Java\Deployment\cache\*") do call :DelTDir "%%j"
    del "%~1\Application Data\Sun\Java\Deployment\cache\." /f /s /q /a
    for /d %%j in ("%~1\Application Data\Sun\Java\Deployment\cache\6.0\*") do call :DelTDir "%%j"
    del "%~1\Application Data\Sun\Java\Deployment\cache\6.0\." /f /s /q /a
    
    
    
    
    echo ===================================================================
    goto :eof
    :DelTDir
    
    
    echo Sletter %~1
    del "%~1\." /q /a 
    rd "%~1"
    goto :eof
    
     
  2. jroe52

    jroe52 Valued Member

  3. CKava

    CKava Just one more thing... Supporter

    Wow jroe you are still around. I didn't know that, thought you disappeared years ago!
     
  4. jroe52

    jroe52 Valued Member

    hehe. well bum shoulder kinda put me off a couple years in everything.

    i keep pushing off wing chun but its what i should get back to most, maybe new years lol.

    this scripts good for saving time running av/antimalware stuff
     
  5. aikiwolfie

    aikiwolfie ... Supporter

    Nice script. Should be useful for fixing PCs for people who still don't understand Windows is Swiss Cheese.
     

Share This Page