Batch File to Cleanup Windows 2000, XP and Server 2003 User Profiles, Temp Folders, Internet Explorer Temporary Files

I’ve had this around for the longest time and figured I better put it here before I lose it forever to the dying Microsoft releases.

Note: This also cleans up VMware temporary files which build up over time. See this post for more information:  VMware Tray Dump Files Chewing up Space

Update: Added line to remove Temporary Internet Files directory/subdirectories also.

@echo off
setlocal
@for /d %%d in ( C:\Documents and Settings\* ) do @(
  echo %%d
  if exist %%d\Application Data\VMware (
    del /q %%d\Application Data\VMware\*.*
  )
  if exist %%d\Local Settings (
    if exist %%d\Local Settings\Temp (
      for /d %%e in ( %%d\Local Settings\Temp\* ) do @(
        attrib -R -A -S -H %%e\*.*
        rmdir %%e /s /q
      )
      if exist %%d\Local Settings\Temporary Internet Files (
        rmdir %%d\Local Settings\Temporary Internet Files /s /q
      )
      if exist %%d\Local Settings\Temp\*.* (
        attrib -R -A -S -H %%d\Local Settings\Temp\*.*
        del %%d\Local Settings\Temp\*.* /q
      )
    )
  )
)

Published by

Rich

Just another IT guy.

2 thoughts on “Batch File to Cleanup Windows 2000, XP and Server 2003 User Profiles, Temp Folders, Internet Explorer Temporary Files”

  1. Great tool! Thanks to your tips-tools-help we are not Caffeine Addicted because you save us a lot of time and we have time also to sleep!!!

Leave a Reply

Your email address will not be published. Required fields are marked *