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.