-
Notifications
You must be signed in to change notification settings - Fork 10
/
cleantemp.bat
95 lines (73 loc) · 3.88 KB
/
cleantemp.bat
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
@SETLOCAL EnableDelayedExpansion
@echo off
rem Securely deletes all known temporary file locations.
rem Requires: sdelete.exe (from sysinternals)
rem Author: Kody Brown (kodybrown@gmail.com)
rem Created 2006-11-04
echo =============================================================================================
echo Removing temporary files..
echo =============================================================================================
echo.
Title Removing temporary files..
set passes=6
for %%G in (C D G) do (
rem if exist "%%G:" (
rem echo checking.. "%%G:\"
exists.exe "%%G:\\"
rem echo ERRORLEVEL=%ERRORLEVEL%
rem echo ERRORLEVEL=!ERRORLEVEL!
if !ERRORLEVEL! equ 0 (
rem echo %%G: exists!
rem Temp files
if exist "%%G:\Temp" call :sdelete "%%G:\Temp"
if exist "%%G:\Windows\Temp" call :delete "%%G:\Windows\Temp"
for %%N in (Kody.Brown Kody KBrown) do (
rem Temp files
if exist "%%G:\Users\%%N\AppData\Local\Temp" call :delete "%%G:\Users\%%N\AppData\Local\Temp"
if exist "%%G:\Documents and Settings\%%N\Local Settings\Temp" call :delete "%%G:\Documents and Settings\%%N\Local Settings\Temp"
rem Recent files history
if exist "%%G:\Users\%%N\AppData\Roaming\Microsoft\Windows\Recent" call :sdelete "%%G:\Users\%%N\AppData\Roaming\Microsoft\Windows\Recent"
if exist "%%G:\Users\%%N\AppData\Roaming\Microsoft\Office\Recent" call :sdelete "%%G:\Users\%%N\AppData\Roaming\Microsoft\Office\Recent"
if exist "%%G:\Users\%%N\AppData\Roaming\Microsoft\VisualStudio\Recent" call :sdelete "%%G:\Users\%%N\AppData\Roaming\Microsoft\VisualStudio\Recent"
rem Epson Scan preview image
if exist "%%G:\Users\%%N\AppData\Roaming\EPSON\ESCNDV\ES0052" call :sdelete "%%G:\Users\%%N\AppData\Roaming\EPSON\ESCNDV\ES0052"
rem Google Chrome cache
if exist "%%G:\Users\%%N\AppData\Local\Google\Chrome\User Data" (
for /f "tokens=*" %%H in ('"dir /ad /b "%%G:\Users\%%N\AppData\Local\Google\Chrome\User Data\*""') do (
if exist "%%G:\Users\%%N\AppData\Local\Google\Chrome\User Data\%%H\Cache" call :delete "%%G:\Users\%%N\AppData\Local\Google\Chrome\User Data\%%H\Cache"
)
)
rem Mozilla Firefox cache
if exist "%%G:\Users\%%N\AppData\Local\Mozilla\Firefox\Profiles" (
for /f "tokens=*" %%H in ('"dir /ad /b "%%G:\Users\%%N\AppData\Local\Mozilla\Firefox\Profiles\*""') do (
if exist "%%G:\Users\%%N\AppData\Local\Mozilla\Firefox\Profiles\%%H\Cache" call :delete "%%G:\Users\%%N\AppData\Local\Mozilla\Firefox\Profiles\%%H\Cache"
)
)
rem Remote Desktop cache
if exist "%%G:\Users\%%N\AppData\Local\Microsoft\Terminal Server Client\Cache" call :delete "%%G:\Users\%%N\AppData\Local\Microsoft\Terminal Server Client\Cache"
rem Remote Desktop cache
if exist "%%G:\Users\%%N\AppData\Local\Microsoft\Windows\SkyDrive\logs" call :delete "%%G:\Users\%%N\AppData\Local\Microsoft\Windows\SkyDrive\logs"
)
)
)
rem if exist "%TEMP%" call :delete "%TEMP%"
rem if exist "%TMP%" call :delete "%TMP%"
Title Command Prompt
if [%1]==[pause] (
pause
) else if [%1]==[-] (
pause
) else if not !ERRORLEVEL! equ 0 (
rem pause
)
@ENDLOCAL && exit /B 0
:sdelete
echo %~1\*.* (secure delete)
echo ---------------------------------------------------------------------------------------------
sdelete.exe -p %passes% -s "%~1\*.*" >nul
goto :eof
:delete
echo %~1\*.* (delete)
echo ---------------------------------------------------------------------------------------------
del /F /Q /S "%~1\*.*" >nul
goto :eof