0

Basically I need to delete all the temporary files and I've got the following script for it. As all the locations are hard coded and not all people use the default location, I was wondering if anyone could help me with script which would be compatible with the current script that would detect all the "Temporary Internet Files" folder's locations from every profiles present and delete the unwanted. The solution would be a great help.

Source: http://www.expertsexchange.com/OS/Microsoft_Operating_Systems/Windows/2000/Q_20794666.html

CODE:


  cls
  SET SRC1=%SYSTEMDRIVE%\Documents and Settings
  SET SRC2=Local Settings\Temporary Internet Files
  SET SRC3=Local Settings\Temp
  SET SRC4=Local Settings\History
  SET SRC5=%SYSTEMROOT%\Temp
  SET SRC6=Cookies


  echo About to delete files from Internet Explorer "Temporary Internet files"
  FOR /D %%X IN ("%SRC1%\*") DO FOR /D %%Y IN ("%%X\%SRC2%\*.*") DO RMDIR /S /Q "%%Y"
  echo About to delete files from "Local settings\temp"
  FOR /D %%X IN ("%SRC1%\*") DO FOR /D %%Y IN ("%%X\%SRC3%\*.*") DO RMDIR  /S /Q "%%Y"
  FOR /D %%X IN ("%SRC1%\*") DO FOR  %%Y IN ("%%X\%SRC3%\*.*") DO DEL /F /S /Q "%%Y"
  echo About to delete files from "Windows\Temp"
  cd\      
  %systemdrive%
  cd /d %SystemRoot%\temp
  del /F /Q *.*
  @echo Y|RD /S ""
  @echo.
  @echo.
  echo About to delete files from "Local Settings\History"
  FOR /D %%X IN ("%SRC1%\*") DO FOR  %%Y IN ("%%X\%SRC4%\*.*") DO DEL /F /S /Q "%%Y"

  FOR /D %%X IN ("%SRC1%\*") DO FOR  %%Y IN ("%%X\%SRC4%\today*.*") DO DEL /F /S /Q "%%Y"

  FOR /D %%X IN ("%SRC1%\*") DO FOR  %%Y IN ("%%X\%SRC4%\*.*") DO DEL /F /S /Q "%%Y"

  echo About to delete files from "%SYSTEMROOT%\Temp"
  FOR /D %%X IN ("%SRC1%\*") DO FOR  %%Y IN ("%%X\%SRC5%\*.*") DO DEL /F /S /Q "%%Y"

  echo About to delete files from "Cookies"
  FOR /D %%X IN ("%SRC1%\*") DO FOR  %%Y IN ("%%X\%SRC6%\*.*") DO DEL /F /S /Q "%%Y"

  @echo            Please review any errors if they exist
  @echo.
  @echo.
Brian Tompsett - 汤莱恩
  • 5,753
  • 72
  • 57
  • 129
user1491091
  • 1
  • 1
  • 1

1 Answers1

1

try the below script...but i'm not sure of the user profile selection...

del /q /s  "c:\winnt\temp\*.*"    
del /q /s  "c:\windows\temp\*.*"    
del /q /s  "%USERPROFILE%\Local Settings\Temp\*.*"    
del /q /s  "%USERPROFILE%\Local Settings\Temporary Internet Files\*.*"    
del /q /s  "%USERPROFILE%\Cookies\*.*"    
del /q /s  "%USERPROFILE%\Recent\*.*"    
Rmdir /q /s "%USERPROFILE%\Local Settings\Temporary Internet Files"    
Rmdir /q /s "%USERPROFILE%\Local Settings\Temp"    
Rmdir /q /s "%USERPROFILE%\Cookies\*.*"    
Rmdir /q /s "c:\winnt\Temp"    
Rmdir /q /s "c:\windows\Temp" 
md  "%USERPROFILE%\Local Settings\Temporary Internet Files"    
md  "%USERPROFILE%\Local Settings\Temp"    
md  "%USERPROFILE%\Cookies"    
md  "c:\winnt\Temp"    
md  "c:\windows\Temp"
Thousand
  • 6,562
  • 3
  • 38
  • 46
Skumar
  • 11
  • 1