User Tools

Site Tools


computing:windows:del_temp

Delete Temporary Files

Windows XP, Vista, 7

Delete temp files for all users:

@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\" 
    )
)

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

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

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.

@echo off
if %os%==Windows_NT goto WINNT
goto NOCON

:WINNT
echo .Using a Windows NT based system
echo ..%computername%

echo Deleting Temporary Internet Files
del /q /f /s "%USERPROFILE%\AppData\Local\Microsoft\Windows\Temporary Internet Files\*.*"
echo deleted!

echo Deleting Downloads Folder Files
del /q /f /s "%USERPROFILE%\Downloads\*.*"
echo deleted!

echo Deleting Cookies
del /q /f /s "%USERPROFILE%\AppData\Roaming\Microsoft\Windows\Cookies\*.*"
del /q /f /s "%USERPROFILE%\AppData\LocalLow\Microsoft\Internet Explorer\DOMStore\*.*"
echo deleted!

echo Deleting History
del /q /f /s "%USERPROFILE%\AppData\Local\Microsoft\Windows\History\*.*"
del /q /f /s "%USERPROFILE%\AppData\Local\Microsoft\Internet Explorer\Recovery\Active\*.*"
del /q /f /s "%USERPROFILE%\AppData\Local\Microsoft\Internet Explorer\Recovery\Last Active\*.*"
echo deleted!

echo Deleting Windows Internet Explorer Dat Files
del /q /f /s "%USERPROFILE%\AppData\Roaming\Microsoft\Windows\PrivacIE\*.*"
del /q /f /s "%USERPROFILE%\AppData\Roaming\Microsoft\Windows\IECompatCache\*.*"
del /q /f /s "%USERPROFILE%\AppData\Roaming\Microsoft\Windows\IETldCache\*.*"
echo deleted!

echo Deleting Windows Error Reporting Files
del /q /f /s "%USERPROFILE%\AppData\Local\Microsoft\Windows\WER\ReportArchive\*.*"
echo deleted!

echo Deleting Flash Player Temp Files
del /q /f /s "%USERPROFILE%\AppData\Roaming\Macromedia\Flash Player\*.*"
echo deleted!

echo Deleting Remote Desktop Cache
del /q /f /s "%USERPROFILE%\AppData\Local\Microsoft\Terminal Server Client\Cache\*.*"
echo deleted!

echo Deleting Profile Temp Files
del /q /f /s "%USERPROFILE%\AppData\Local\Temp\*.*"
echo deleted!

echo Delete misc Files in Profile
del /q /f /s "%USERPROFILE%\webct_upload_applet.properties"
del /q /f /s "%USERPROFILE%\g2mdlhlpx.exe"
del /q /f /s "%USERPROFILE%\fred"
rmdir /s /q "%USERPROFILE%\temp"
rmdir /s /q "%USERPROFILE%\WebEx"
rmdir /s /q "%USERPROFILE%\.gimp-2.4"
rmdir /s /q "%USERPROFILE%\.realobjects"
rmdir /s /q "%USERPROFILE%\.thumbnails"
rmdir /s /q "%USERPROFILE%\Bluetooth Software"
rmdir /s /q "%USERPROFILE%\Office Genuine Advantage"
echo deleted!

echo Deleting FireFox Cache

pushd "%USERPROFILE%\AppData\Local\Mozilla\Firefox\Profiles\*.default\"
del /q /f /s "Cache\*.*"
popd

echo deleted!

echo Deleting User Profile Adobe Temp Files
del /q /f /s "%USERPROFILE%\AppData\LocalLow\Adobe\Acrobat\9.0\Search\*.*"
del /q /f /s "%USERPROFILE%\AppData\LocalLow\Adobe\Common\Media Cache Files\*.*"
del /q /f /s "%USERPROFILE%\AppData\LocalLow\Adobe\Common\Media Cache\*.*"
echo deleted!

echo Deleting User Office Recent Files
del /q /f /s "%USERPROFILE%\AppData\Roaming\Microsoft\Office\Recent\*.*"
echo deleted!

echo Deleting User Office TMP Files
del /q /f /s "%USERPROFILE%\AppData\Roaming\Microsoft\Office\*.tmp"
echo deleted!

goto END

:NOCON
echo Error...Invalid Operating System...
echo Error...No actions were made...
goto END

:END
computing/windows/del_temp.txt · Last modified: 2013/07/18 14:17 by gcooper