Contact US

Log In

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!

*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here


Script: Temp File Cleaner by hgate73
Posted: 17 Apr 10

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.


:: 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

@echo off
color f0
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 Temp files cleaned.

Back to Microsoft: Windows FAQ Index
Back to Microsoft: Windows Forum

My Archive

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close