Skip to content

Instantly share code, notes, and snippets.

@katalin2003
Forked from zalmyr/clean.bat
Last active August 29, 2015 14:28
Show Gist options
  • Save katalin2003/5f9f7f5fbf1bfc45dbc1 to your computer and use it in GitHub Desktop.
Save katalin2003/5f9f7f5fbf1bfc45dbc1 to your computer and use it in GitHub Desktop.
BATCH: Clean Windows 7 Temp Files
REM Created by Zalmy Rosenberg © 2015
start /wait taskkill /im iexplore.exe /t /f
start /wait taskkill /im firefox.exe /t /f
start /wait taskkill /im chrome.exe /t /f
set user=C:\Users
set dest2=AppData\Local\Microsoft\Windows\Temporary Internet Files
set ffPath=AppData\Local\Mozilla\Firefox\Profiles
set chromePath=AppData\Local\Google\Chrome\User Data\Default\Cache
set localTempPath=AppData\Local\Temp
for /f "tokens=*" %%G in (
'dir /b /a:d "%user%"'
) do (
(REM Delete Temp Internet Files IE
if exist "%user%\%%G\%dest2%\" (del /s /q "%user%\%%G\%dest2%\*"
attrib /D /S -h -s "%user%\%%G\%dest2%\*"
for /f "tokens=*" %%5 in ('dir /A:D /b "%user%\%%G\%dest2%\"') do rd /S /Q "%user%\%%G\%dest2%\%%5"
)
)
(REM Firefox Temporary Files
if exist "%user%\%%G\%ffPath%" (
for /f %%H in ('dir /b /a:d %user%\%%G\%ffPath%') do (
del /s /q %user%\%%G\%ffPath%\%%H\cache2\*
del /s /q %user%\%%G\%ffPath%\%%H\OfflineCache\*
del /s /q %user%\%%G\%ffPath%\%%H\startupCache\*
del /s /q %user%\%%G\%ffPath%\%%H\safebrowsing\*
)
)
)
(REM Chrome Temp Files
if exist "%user%\%%G\%chromePath%" (
del /s /q "%user%\%%G\%chromePath%\*"
)
)
(REM Clean Windows Temp Files
echo "%user%\%%G\%localTempPath%\*"
if exist "%user%\%%G\%localTempPath%\" (
echo "%user%\%%G\%localTempPath%\\*" >> c:\users\josephs\desktop\ksm.log
attrib /D /S -h -s "%user%\%%G\%localTempPath%\\*"
del /s /q "%user%\%%G\%localTempPath%\\*"
for /f "tokens=*" %%d in ('dir /b /a:d "%user%\%%G\%localTempPath%\"') do rd /S /Q "%user%\%%G\%localTempPath%\\%%d"
)
)
)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment