User Tools

Site Tools


computing:windows:del_temp

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revision Previous revision
Next revision
Previous revision
computing:windows:del_temp [2013/04/17 13:01]
gcooper
computing:windows:del_temp [2013/07/18 14:17] (current)
gcooper
Line 1: Line 1:
 ====== Delete Temporary Files ====== ====== Delete Temporary Files ======
  
-This script will delete various temporary files and folders on a per-user basis.+===== Windows XP, Vista, 7 =====
  
-This batch file was evidently designed to be run as a logoff script.+Delete temp files for all users: 
 + 
 +<file> 
 +@echo off 
 + 
 +IF EXIST c:\windows\temp\ del /f /s /q c:\windows\temp\ 
 + 
 +DEL /f /s /q %temp%\ 
 + 
 +IF EXIST "C:\Users\"
 +    for /D %%x in ("C:\Users\*") do (  
 +        del /f /s /q "%%x\AppData\Local\Temp\"  
 +        del /f /s /q "%%x\AppData\Local\Microsoft\Windows\Temporary Internet Files\"  
 +    ) 
 +
 + 
 +IF EXIST "C:\Documents and Settings\"
 +    for /D %%x in ("C:\Documents and Settings\*") do (  
 +        del /f /s /q "%%x\Local Settings\Temp\"  
 +        del /f /s /q "%%x\Local Settings\Temporary Internet Files\"  
 +    ) 
 +
 +</file> 
 + 
 +===== Terminal Server (RDS) Script ===== 
 + 
 +http://stackoverflow.com/questions/14071021/batch-file-to-delete-firefox-cache-for-user-profiles-on-terminal-server 
 + 
 +FIXME This script did not work on Server 2003 
 + 
 +<file> 
 +:: Hide Commands 
 +@echo off 
 +setlocal EnableExtensions 
 + 
 +:: Parse the Local AppData sub path 
 +call :Expand xAppData "%%LocalAppData:%UserProfile%=%%" 
 + 
 +set "xFirefox=\mozilla\firefox\profiles" 
 +set "xChrome=\google\chrome\user data" 
 + 
 +:: Start at the User directory 
 +pushd "%UserProfile%\.." 
 + 
 +:: Loop through the Users 
 +for /D %%D in (*) do if exist "%%~fD%xAppData%"
 +    rem Check for Firefox 
 +    if exist "%%~fD%xAppData%%xFirefox%"
 +        pushd "%%~fD%xAppData%%xFirefox%" 
 + 
 +        rem Loop through the Profiles 
 +        for /D %%P in (*) do ( 
 +            if exist "%%~fP\cache" echo "%%~fP\cache" 
 +        ) 
 +        popd 
 +    ) 
 + 
 +    rem Check for Chrome 
 +    if exist "%%~fD%xAppData%%xChrome%"
 +        pushd "%%~fD%xAppData%%xChrome%" 
 + 
 +        rem Loop through the Profiles 
 +        for /D %%P in (*) do ( 
 +            if exist "%%~fP\cache" echo "%%~fP\cache" 
 +        ) 
 +        popd 
 +    ) 
 +
 +popd 
 +goto End 
 + 
 + 
 +:::::::::::::::::::::::::::::: 
 +:Expand <Variable> <Value> 
 +if not "%~1"=="" set "%~1=%~2" 
 +goto :eof 
 + 
 + 
 +:End 
 +endlocal 
 +pause 
 +</file> 
 + 
 +===== Logoff Script ===== 
 + 
 +http://community.spiceworks.com/scripts/show/782-user-cleanup 
 + 
 +This batch file will delete various temporary files and folders on a per-user basis.
  
 <file> <file>
computing/windows/del_temp.1366225305.txt.gz · Last modified: 2013/04/17 13:01 by gcooper