-
Notifications
You must be signed in to change notification settings - Fork 7
/
Copy pathWindowsCleanerUtility.bat
254 lines (211 loc) · 9.47 KB
/
WindowsCleanerUtility.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
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
@echo off
mode con cols=122 lines=40
chcp 65001
cls
REM --> Check for permissions
>nul 2>&1 "%SYSTEMROOT%\system32\cacls.exe" "%SYSTEMROOT%\system32\config\system"
REM --> If error flag set, we do not have admin.
if '%errorlevel%' NEQ '0' (
echo Requesting administrative privileges...
goto UACPrompt
) else ( goto gotAdmin )
:UACPrompt
echo Set UAC = CreateObject^("Shell.Application"^) > "%temp%\getadmin.vbs"
echo UAC.ShellExecute "%~s0", "", "", "runas", 1 >> "%temp%\getadmin.vbs"
"%temp%\getadmin.vbs"
exit /B
:gotAdmin
if exist "%temp%\getadmin.vbs" ( del "%temp%\getadmin.vbs" )
pushd "%CD%"
CD /D "%~dp0"
echo Windows Cleaner Utility Launcher by Chainski Tools
goto int
:int
echo Loading configuration, please wait ...
cls
set VER=1.0.0
set dir=%temp%
set github-link=https://github.com/Chainski/WindowsCleanerUtility
set license=GNU GENERAL PUBLIC LICENSE (version 3)
set license-file=LICENSE.txt
timeout 1 /nul
goto menu
:menu
cls
echo [40;31m ╔╗╔╗╔╗╔══╗╔═╗ ╔╗╔═══╗╔═══╗╔╗╔╗╔╗╔═══╗ [40;34m ╔═══╗╔╗ ╔═══╗╔═══╗╔═╗ ╔╗╔═══╗╔═══╗ [40;31m ╔╗ ╔╗╔════╗╔══╗╔╗ ╔══╗╔════╗╔╗ ╔╗
echo [40;31m ║║║║║║╚╣╠╝║║╚╗║║╚╗╔╗║║╔═╗║║║║║║║║╔═╗║ [40;34m ║╔═╗║║║ ║╔══╝║╔═╗║║║╚╗║║║╔══╝║╔═╗║ [40;31m ║║ ║║║╔╗╔╗║╚╣╠╝║║ ╚╣╠╝║╔╗╔╗║║╚╗╔╝║
echo [40;31m ║║║║║║ ║║ ║╔╗╚╝║ ║║║║║║ ║║║║║║║║║╚══╗ [40;34m ║║ ╚╝║║ ║╚══╗║║ ║║║╔╗╚╝║║╚══╗║╚═╝║ [40;31m ║║ ║║╚╝║║╚╝ ║║ ║║ ║║ ╚╝║║╚╝╚╗╚╝╔╝
echo [40;31m ║╚╝╚╝║ ║║ ║║╚╗║║ ║║║║║║ ║║║╚╝╚╝║╚══╗║ [40;34m ║║ ╔╗║║ ╔╗║╔══╝║╚═╝║║║╚╗║║║╔══╝║╔╗╔╝ [40;31m ║║ ║║ ║║ ║║ ║║ ╔╗ ║║ ║║ ╚╗╔╝
echo [40;31m ╚╗╔╗╔╝╔╣╠╗║║ ║║║╔╝╚╝║║╚═╝║╚╗╔╗╔╝║╚═╝║ [40;34m ║╚═╝║║╚═╝║║╚══╗║╔═╗║║║ ║║║║╚══╗║║║╚╗ [40;31m ║╚═╝║ ╔╝╚╗ ╔╣╠╗║╚═╝║╔╣╠╗ ╔╝╚╗ ║║
echo [40;31m ╚╝╚╝ ╚══╝╚╝ ╚═╝╚═══╝╚═══╝ ╚╝╚╝ ╚═══╝ [40;34m ╚═══╝╚═══╝╚═══╝╚╝ ╚╝╚╝ ╚═╝╚═══╝╚╝╚═╝ [40;31m ╚═══╝ ╚══╝ ╚══╝╚═══╝╚══╝ ╚══╝ ╚╝
echo.
echo.
echo [40;33m ╔════════════════════════════════╗
echo [40;33m ║ Windows Cleaner Utility ║
echo [40;33m ║ coded by Chainski Tools ║
echo [40;33m ╚════════════════════════════════╝
title Windows Cleaner Utility %ver% by Chainski Tools
echo.
echo [40;32m Press a button from 1 to 5 - each of these buttons has its own function as described below:
echo.
echo 1 - Delete the Temporary Files
echo.
echo 2 - Scan System And Repair Windows Image
echo.
echo 3 - Program and license information
echo.
echo 4 - Page on GitHub
echo.
echo 5 - End session (will close the program)
choice /c 12345 /n
if %errorlevel%==1 goto clear-init
if %errorlevel%==2 goto Repair
if %errorlevel%==3 goto info
if %errorlevel%==4 goto github
if %errorlevel%==5 goto End
:END
cls
exit
:Repair
cls
sfc /scannow
DISM /Online /Cleanup-Image /CheckHealth
DISM /Online /Cleanup-Image /ScanHealth
DISM /Online /Cleanup-Image /RestoreHealth
cls
echo Windows Repaired Successfully!
echo --------------------------------------------------
echo Press ENTER KEY yo Continue.
echo --------------------------------------------------
pause >nul
goto menu
:clear-init
cls
echo Checking Temporary Files...
cd %temp%
if exist * goto clear-warning
if not exist * goto good-to-go
:clear-warning
cls
echo.
echo Your PC needs deep cleaning! Select an option below to continue.
echo.
echo Press 1 to clear data and reclaim disk space. (This process make several minutes please be patient)
echo Press 2 to stop the current operations and exit the program.
choice /c 12 /n
if %errorlevel%==1 goto clear
if %errorlevel%==2 exit
:clear
rem Delete Temporary Files
RMDIR "%tmp%" /S /Q >nul 2>nul
del /s /f /q %temp%\*.* >nul 2>nul
cleanmgr.exe /autoclean :: Used to delete old files left after upgrading a Windows build
del /s /f /q %windir%\temp\*.* >nul 2>nul
cls
echo [Cleaning] and Optimizations in progress...
timeout /t 2 /nobreak >nul
echo.
echo [Cleaning] Temporary Files && color c
timeout /t 2 /nobreak >nul
echo.
:: Empties the RecycleBin
del /s /q /f %systemdrive%\$Recycle.bin\* >nul 2>nul
del /s /f /q %windir%\temp\*.* >nul 2>nul
del /s /f /q %windir%\Prefetch\*.* >nul 2>nul
del /s /f /q %LOCALAPPDATA%\Microsoft\Windows\Caches\*.* >nul 2>nul
del /s /f /q %windir%\SoftwareDistribution\Download\*.* >nul 2>nul
del /s /f /q %programdata%\Microsoft\Windows\WER\Temp\*.* >nul 2>nul
del /s /f /q %HomePath%\AppData\LocalLow\Temp\*.* >nul 2>nul
del /f /s /q %systemdrive%\*.tmp 2>nul >nul
rd /s /f /q %windir%\history 2>nul >nul
rd /s /f /q %windir%\cookies 2>nul >nul
echo [Cleaning] Log Files && color b
timeout /t 2 /nobreak >nul
echo.
REM Delete Log Files
del /f /s /q %systemdrive%\*.log >nul 2>nul
del /f /s /q %systemdrive%\*.old >nul 2>nul
del /f /s /q %systemdrive%\*.trace >nul 2>nul
del /f /s /q %windir%\*.bak >nul 2>nul
del /s /f /q %windir%\Logs\CBS\CbsPersist*.log >nul 2>nul
del /s /f /q %windir%\Logs\MoSetup\*.log >nul 2>nul
del /s /f /q %windir%\Panther\*.log >nul 2>nul
del /s /f /q %windir%\logs\*.log >nul 2>nul
del /s /f /q %localappdata%\Microsoft\Windows\WebCache\*.log >nul 2>nul
rd /s /f /q %localappdata%\Microsoft\Windows\INetCache\*.log >nul 2>nul
:: Remove Event Logs.
wevtutil.exe cl Application
wevtutil.exe cl System
echo [Cleaning] Remnant Driver Files && color 9
timeout /t 2 /nobreak >nul
echo.
rem Delete Remnant Driver Files (Not needed because already installed)
del /s /f /q %SYSTEMDRIVE%\AMD\*.* >nul 2>nul
del /s /f /q %SYSTEMDRIVE%\NVIDIA\*.* >nul 2>nul
del /s /f /q %SYSTEMDRIVE%\INTEL\*.* >nul 2>nul
echo [Cleaning] Windows Defender Cache/Logs && color 3
timeout /t 2 /nobreak >nul
echo.
del "%ProgramData%\Microsoft\Windows Defender\Network Inspection System\Support\*.log" /F /Q /S >nul 2>nul
del "%ProgramData%\Microsoft\Windows Defender\Scans\History\CacheManager" /F /Q /S >nul 2>nul
del "%ProgramData%\Microsoft\Windows Defender\Scans\History\ReportLatency\Latency" /F /Q /S >nul 2>nul
del "%ProgramData%\Microsoft\Windows Defender\Scans\History\Service\*.log" /F /Q /S >nul 2>nul
del "%ProgramData%\Microsoft\Windows Defender\Scans\MetaStore" /F /Q /S >nul 2>nul
del "%ProgramData%\Microsoft\Windows Defender\Support" /F /Q /S >nul 2>nul
del "%ProgramData%\Microsoft\Windows Defender\Scans\History\Results\Quick" /F /Q /S >nul 2>nul
del "%ProgramData%\Microsoft\Windows Defender\Scans\History\Results\Resource" /F /Q /S >nul 2>nul
echo [Cleaning] DNS Resolver Cache && color 2
timeout /t 2 /nobreak >nul
echo.
REM Clean DNS Resolver Cache (Restart May Be Required)
ipconfig /release >nul 2>nul
ipconfig /renew >nul 2>nul
ipconfig /flushdns >nul 2>nul
netsh int ip reset >nul 2>nul
netsh winsock reset >nul 2>nul
netsh interface ipv4 reset >nul 2>nul
netsh interface ipv6 reset >nul 2>nul
echo [Enabling] Ultimate Performance Mode && color b
timeout /t 2 /nobreak >nul
echo.
echo Successfully Enabled Ultimate Performance Mode ! && color c
timeout /t 2 /nobreak >nul
echo.
::Enables Ultimate Performance
powercfg -duplicatescheme e9a42b02-d5df-448d-aa00-03f14749eb61 95533644-e700-4a79-a56c-a89e8cb109d9 >nul 2>nul
powercfg -setactive 95533644-e700-4a79-a56c-a89e8cb109d9 >nul 2>nul
:clear-error
echo Unfortunately, we were unable to remove all of the Temporary files (some are being used by other processes).
echo You can manually open the Temporary Folders and try to delete the remaining files.
echo.
echo Press 1 to try again.
echo Press 2 to return to the menu.
choice /c 12 /n
if %errorlevel%==1 goto clear
if %errorlevel%==2 goto menu
if exist * goto clear-error
if not exist * goto clear-complete
:clear-complete
cls
echo Ready! Your computer has been cleared of unnecessary temporary data!
pause
goto menu
:good-to-go
cls
echo Your PC doesn't need any cleaning. Your PC is good to go!
pause
goto menu
:info
cls
echo Windows Cleaner Utility
echo %ver% by Chainski
echo.
echo Source code avaible on GitHub: %github-link%
echo Working under license: %license%
echo.
pause /nul
goto menu
:github
cls
start %github-link%
goto menu