Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Script: Temp File Cleaner

Performance

Script: Temp File Cleaner

by  hgate73  Posted    (Edited  )
This is a basic temp file cleaner script. It also cleans Flash cookies - something most people overlook.

It deletes random stuff sitting in C:\ too - so if you store files in C:\ (the root of the drive) then remove this section.

Copy and paste this into a .bat file.

Code:
:: Purpose:            Temp file cleanup
:: Requirements:    Admin access
:: Author:            Harbor Gate
:: Version:            1.6
:: History:            1.6 Changed some delete flags to /F /S /Q instead of just /F /Q
::                        The "/S" flag says to recurse into subdirectories.
::                    1.5 Added new areas to clean -- %TEMP%\ folder
::                    1.0 Initial write

::prepare
@echo off
color f0
cd\
cls
title [CLEANING]

:: User temp files
del "%TEMP%\*" /F /S /Q

:: Root drive garbage (usually C drive)
del "%SystemDrive%\*.bat" /F /Q
del "%SystemDrive%\*.txt" /F /Q
del "%SystemDrive%\*.jp*" /F /Q
del "%SystemDrive%\*.log*" /F /Q
del "%SystemDrive%\*.t*mp" /F /Q
del "%SystemDrive%\*.bak*" /F /Q

:: System temp cache
del "%WINDIR%\TEMP\*" /F /S /Q

:: Flash cookies
del %appdata%\Macromedia\Flash Player\#SharedObjects\*

:: User history and temp files
del "%SystemDrive%%HOMEPATH%\Recent\*.*" /F /Q
del "%SystemDrive%%HOMEPATH%\Local Settings\Temp\*.*" /F /Q
del "%SystemDrive%%HOMEPATH%\Local Settings\Temporary Internet Files\*.*" /F /Q
del "%SystemDrive%%HOMEPATH%\Local Settings\Application Data\ApplicationHistory\*.*" /F /Q
del "%SystemDrive%%HOMEPATH%\My Documents\*.tmp"
del "%SystemDrive%%HOMEPATH%\My Documents\*.bak"
del "%SystemDrive%%HOMEPATH%\My Documents\*.log"

:: complete
@echo off
title [COMPLETE]
echo.
echo.
echo Temp files cleaned.
echo.
Register to rate this FAQ  : BAD 1 2 3 4 5 6 7 8 9 10 GOOD
Please Note: 1 is Bad, 10 is Good :-)

Part and Inventory Search

Back
Top