View difference between Paste ID: e6K5gJBG and gNsLEWJe
SHOW: | | - or go back to the newest paste.
1-
@set @version=10.5 /* &title Windows Update Toggle
1+
@set @version=10.1 /* &title Windows Update Toggle
2
@echo off
3-
exit /b [OUTDATED] 
3+
4
echo      ---------------------------------------------------------------------
5
echo     :                     Windows Update Toggle v10.1                     :
6
echo     :---------------------------------------------------------------------:
7
echo     :         Block/Enable Upgrades, Installs, Downloads, Service         :
8-
echo     :                     Windows Update Toggle v10.5                     :
8+
9
echo     :        Hide/Unhide/Apply update lists with count and max size       :
10
echo     :         Preset Defender updates and Store downloads working         :
11
echo     :                                                                     :
12
echo     :     Toggle from the comfort of Desktop right-click context menu     :
13
echo      ---------------------------------------------------------------------
14
echo.
15
:: 2018-05-15 v10.1: streamlined toggling with a nicer gui
16
:: Focus set on Defender updates working independently from windows mayhem automatic updates
17
:: so this script will not sacrifice built-in protection layer, unlike most other -DIY- updates "management" just killing wuauserv
18-
:: 2020-09-07 v10.4: downloads option fixed and selected by default. stay tuned for a redesigned version with less hard blocks
18+
19
:: had to use separate context menus for each category due to limitation of max 16 cascading items.. tx bill gates, 2018
20
:: if Defender protection updates are detected in the Apply list, a manual signature update is set to trigger
21
:: SearchUI option will disable start menu search - obviously, but you can use Classic Shell instead to have it working
22
:: Disable option provided for wuauserv, but not recommended since a lot of stuff depends on it
23
:: Mostly IFEO safe blocking with no destructive changes of ownership, deleting files, removing tasks, or over-blocking
24
:: Troubleshooter option will just revert blocking done by this and former suite scripts; launches official update troubleshooter
25
:: If blocking caused an unlikely logon issue, do advanced startup-troubleshoot-commandprompt and run WUTUndo.bat from C:\Windows
26
:: There is a lot of ping-pong in the backend between CMD and WScript to bypass popups and prompts, yet neatly structured script
27
:: AveYo, 2018-05-13
28
29
if %1.==. timeout /t 10 &call wscript /e:JScript "%~f0" runas setup &exit &rem : no arguments, run setup elevated
30
if %1.==shift. shift &shift &rem : if loaded by WScript, shift args to prevent loop and restore %0
31
if %1.==. echo ERROR! &timeout /t 5 &exit/b : must have at least one arg
32
33
:: Setup executable blocking via ifeo
34
set notifier=EOSNotify MusNotification
35
set upgrader=Windows10UpgraderApp Windows10Upgrade WindowsUpdateBox SetupHost setupprep
36
set installer=wuauclt
37
set reporter=wermgr wsqmcons DiagTrackRunner DiagnosticsHub.StandardCollector.Service CompatTelRunner
38
set speecher=SpeechRuntime SpeechModelDownload
39
set searcher=SearchUI
40
41-
set downloader=MoUsoCoreWorker sedlauncher sedsvc
41+
set "exe=%notifier% %upgrader% %installer% %reporter%"
42
set "noop=%SystemRoot%\system32\systray.exe"
43
set "ifeo=HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Image File Execution Options"
44
set "wut=HKCR\DesktopBackground\shell\WUT"
45
set "menu=%wut%\shell"
46-
set "exe=%notifier% %upgrader% %installer% %downloader% %reporter%"
46+
47
set ".=>nul 2>nul"
48
set "verbose="
49
50
for /f "tokens=2 delims=1234567890" %%# in ('shutdown /?^|findstr /bc:"E"') do set "[T]=%%#" &rem : cosmetic usage in menus
51
if defined verbose (echo on &set ".=" &set "window=") else set "window=hide"
52
call :%~1 %2 %3 %4 %5 %6 %7 %8 %9 &rem : launch secondary functions below dinamically, passing next args
53
echo.
54
echo Done! Use the Desktop right-click context menu to toggle, renew or uninstall
55-
for /f "tokens=2 delims=1234567890" %%a in ('shutdown /?^|findstr /bc:"E"') do set "[T]=%%a" &rem : cosmetic usage in menus
55+
56
57
exit/b : End of main script, functions below
58
::---------------------------------------------------------------------------------------------------------------------------------
59
60
:refresh context menu
61
echo %0 %*
62
call :reg_query "HKLM\SOFTWARE\WUT.bat" NoBlock noblock
63
if "%noblock%"=="Enable" exit/b
64
call :reg_query "%wut%0pending" MUIVerb pending
65
if defined pending exit/b
66
for %%# in ("1hide" "2unhide" "3apply") do reg delete "%wut%%%~#" /f %.%
67
reg add "%wut%0pending" /v MUIVerb /d "Pending.." /f %.%
68
reg add "%wut%0pending" /v Icon /d "ieframe.dll,11" /f %.%
69
reg add "%wut%0pending" /v SubCommands /d "" /f %.%
70
call :reg_query "HKLM\SOFTWARE\WUT.bat" NoRefresh norefresh
71-
for %%a in ("1hide" "2unhide" "3apply") do reg delete "%wut%%%~a" /f %.%
71+
72
reg add "%menu%\2Lists"  /v Icon /d "ieframe.dll,%toggle%" /f %.%
73
if "%norefresh%"=="Disable" start "WUT" wscript /e:JScript "%f0%" WUTRefresh
74
call :status SetupHost 3Upgrades
75
call :status wuauclt 4Installs
76
for /f "tokens=3" %%# in ('sc qc TrustedInstaller ^| find /I "WUTblocked"') do set "blocked=%%#"
77
if /i "%blocked%"=="[WUTblocked]" (set "toggle=38") else set "toggle=39"
78
reg add "%menu%\5Downloads"  /v Icon /d "ieframe.dll,%toggle%" /f %.%
79
for /f "tokens=3" %%# in ('sc qc wuauserv ^| find /I "WUTblocked"') do set "blocked=%%#"
80
if /i "%blocked%"=="rpcss[WUTblocked]" (set "toggle=38") else set "toggle=39"
81-
call :status MoUsoCoreWorker 5Downloads
81+
82-
rem for /f "tokens=3" %%a in ('sc qc TrustedInstaller ^| find /I "WUTblocked"') do set "blocked=%%a"
82+
83-
rem if /i "%blocked%"=="[WUTblocked]" (set "toggle=38") else set "toggle=39"
83+
84-
rem reg add "%menu%\5Downloads"  /v Icon /d "ieframe.dll,%toggle%" /f %.%
84+
85-
for /f "tokens=3" %%a in ('sc qc wuauserv ^| find /I "WUTblocked"') do set "blocked=%%a"
85+
86
for /f "delims=" %%# in ('call powershell.exe -c "%defstatus%;"') do set "toggle=%%#"
87
reg add "%menu%\84Defender"  /v Icon /d "ieframe.dll,%toggle%" /f %.%
88
if "%norefresh%"=="Enable" reg delete "%wut%0pending" /f %.%
89
exit/b
90
91
:status %1:exe %2:submenu
92-
for /f "delims=" %%a in ('call powershell.exe -c "%defstatus%;"') do set "toggle=%%a"
92+
93
if defined block (set "toggle=38") else set "toggle=39"
94
reg add "%menu%\%~2"  /v Icon /d "ieframe.dll,%toggle%" /f %.%
95
exit/b
96
97
:flip %1:exe %2:submenu
98
call :reg_query "%ifeo%\%~1.exe" Debugger block
99
if defined block (set "toggle=39") else set "toggle=38"
100
reg add "%menu%\%~2"  /v Icon /d "ieframe.dll,%toggle%" /f %.%
101
exit/b
102
103
:toggle WUT
104
echo %0 %*
105
call :reg_query "HKLM\SOFTWARE\WUT.bat" NoBlock noblock
106
if "%noblock%"=="Disable" (set "toggle=Enable") else set "toggle=Disable"
107
for %%# in (NoBlock NoRefresh) do reg add "HKLM\SOFTWARE\WUT.bat" /v %%# /d "%toggle%" /f %.%
108
set "task=wscript.exe /e:JScript \"%f0%\" schtasks WUT"
109
:: Generate WUT main context menu
110
for %%# in ("" "0pending" "1hide" "2unhide" "3apply") do reg delete "%wut%%%~#" /f %.%
111
reg add "%wut%" /v MUIVerb /d "Windows Update Toggle" /f %.%
112
reg add "%wut%" /v Icon /d "comres.dll,4" /f %.%
113-
for %%a in (NoBlock NoRefresh) do reg add "HKLM\SOFTWARE\WUT.bat" /v %%a /d "%toggle%" /f %.%
113+
114
reg add "%menu%\9Setup" /v MUIVerb /d "Configure WUT v%@version:~0,4%" /f %.%
115
reg add "%menu%\9Setup" /v SubCommands /d "" /f %.%
116-
for %%a in ("" "0pending" "1hide" "2unhide" "3apply") do reg delete "%wut%%%~a" /f %.%
116+
117
reg add "%menu%\9Setup\shell\2Renew"   /v MUIVerb /d "Renew" /f %.%
118
reg add "%menu%\9Setup\shell\3Remove"  /v MUIVerb /d "Remove" /f %.%
119
reg add "%menu%\9Setup\shell\1Toggle\command" /ve /d "%task%\toggle" /f %.%
120
reg add "%menu%\9Setup\shell\2Renew\command"  /ve /d "%task%\renew" /f %.%
121
reg add "%menu%\9Setup\shell\3Remove\command" /ve /d "%task%\remove" /f %.%
122
if "%toggle%"=="Disable" (
123
 reg add "%menu%\1Refresh"    /v MUIVerb /d "Refresh" /f %.%
124
 reg add "%menu%\2Lists"      /v MUIVerb /d "Lists" /f %.%
125
 reg add "%menu%\3Upgrades"   /v MUIVerb /d "Upgrades %[T]% setuphost" /f %.%
126
 reg add "%menu%\4Installs"   /v MUIVerb /d "Installs %[T]% wuauclt" /f %.%
127
 reg add "%menu%\5Downloads"  /v MUIVerb /d "Downloads ! %[T]% trustedinstaller" /f %.%
128
 reg add "%menu%\6Service"    /v MUIVerb /d "Service ! ! %[T]% wuauserv" /f %.%
129
 reg add "%menu%\7Repair"     /v MUIVerb /d "Troubleshooter" /f %.%
130
 reg add "%menu%\81Report"    /v MUIVerb /d "Report" /f %.%
131
 reg add "%menu%\82Speech"    /v MUIVerb /d "Speech" /f %.%
132
 reg add "%menu%\83Search"    /v MUIVerb /d "SearchUI" /f %.%
133
 reg add "%menu%\84Defender"  /v MUIVerb /d "Defender" /f %.%
134
 reg add "%menu%\1Refresh\command" /ve   /d "%task%\refresh" /f %.%
135
 reg add "%menu%\2Lists\command" /ve     /d "%task%\lists" /f %.%
136
 reg add "%menu%\3Upgrades\command" /ve  /d "%task%\upgrades" /f %.%
137
 reg add "%menu%\4Installs\command" /ve  /d "%task%\installs" /f %.%
138
 reg add "%menu%\5Downloads\command" /ve /d "%task%\downloads" /f %.%
139
 reg add "%menu%\6Service\command" /ve   /d "%task%\service" /f %.%
140
 reg add "%menu%\7Repair\command" /ve    /d "%task%\repair" /f %.%
141
 reg add "%menu%\81Report\command" /ve   /d "%task%\report" /f %.%
142
 reg add "%menu%\82Speech\command" /ve   /d "%task%\speech" /f %.%
143
 reg add "%menu%\83Search\command" /ve   /d "%task%\search" /f %.%
144
 reg add "%menu%\84Defender\command" /ve /d "%task%\defender" /f %.%
145
)
146
:: Toggle immersive context-menu crap
147
::if "%toggle%"=="Disable" set "icm=0x0" else set "icm=0x1"
148
::reg add "HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\FlightedFeatures" /v ImmersiveContextMenu /t REG_DWORD /d %icm% /f %.%
149
:: Disabling automatic updates hinders Defender, so get definitions from MMPC first
150
set "DefMUS={MicrosoftUpdateServer|MMPC|InternalDefinitionUpdateServer}"
151
set "DefMMPC={MMPC|MicrosoftUpdateServer|InternalDefinitionUpdateServer}"
152
if "%toggle%"=="Enable" ( set "DefSig=%DefMUS%" ) else set "DefSig=%DefMMPC%"
153
start "WUT:MpPref" wscript /e:JScript "%~f0" cmd "powershell.exe -c `Set-MpPreference -SignatureFallbackOrder %DefSig%;`"
154
:: Default services
155
sc config wuauserv type= share depend= rpcss %.%
156
sc config TrustedInstaller type= own depend= / %.%
157
:: Toggle ifeo exe blocking
158
for %%# in (%exe% %speech% %search%) do reg delete "%ifeo%\%%#.exe" /f %.%
159
if "%toggle%"=="Enable" exit/b WUT disabled, so skip the code below
160
for %%# in (%exe%) do reg add "%ifeo%\%%#.exe" /v Debugger /d "%noop%" /f %.% &taskkill /im "%%#.exe" /t /f %.%
161
:: WUTRefresh hijacking
162
for %%# in (MusNotification EOSNotify) do reg add "%ifeo%\%%#.exe" /v Debugger /d "%SystemRoot%\WUTRefresh.bat" /f %.%
163
call :refresh menu
164-
for %%a in (%exe% %speech% %search%) do reg delete "%ifeo%\%%a.exe" /f %.%
164+
165
166-
for %%a in (%exe%) do reg add "%ifeo%\%%a.exe" /v Debugger /d "%noop%" /f %.% &taskkill /im "%%a.exe" /t /f %.%
166+
167-
:: Block downloads on older version - a mess atm
167+
168-
net stop TrustedInstaller %.%
168+
169-
sc config TrustedInstaller type= own depend= [WUTblocked] %.%
169+
170
if not defined updatefound exit/b
171-
for %%a in (MusNotification EOSNotify) do reg add "%ifeo%\%%a.exe" /v Debugger /d "%SystemRoot%\WUTRefresh.bat" /f %.%
171+
172
exit/b
173
174
:unhide update
175
echo %0 %*
176
call :reg_query "%wut%2unhide\shell\%~1" MUIVerb updatefound
177
echo -%updatefound%
178
if not defined updatefound exit/b
179
call wscript /e:JScript "%f0%" unhide "%updatefound%"
180
exit/b
181
182
:apply update
183
echo %0 %*
184
call :reg_query "%wut%3apply\shell\%~1" MUIVerb updatefound
185
echo -%updatefound%
186
if not defined updatefound exit/b
187
:: Cache current blocks status, because Apply will unblock downloads and installs in the WScript stage
188
call :reg_query "%ifeo%\wuauclt.exe" Debugger installs_blocked
189
for /f "tokens=3" %%# in ('sc qc TrustedInstaller ^| find /I "WUTblocked"') do set "downloads_blocked=%%#"
190
call wscript /e:JScript "%f0%" apply "%updatefound%"
191
:: Restore cached blocks
192
if defined installs_blocked reg add "%ifeo%\wuauclt.exe" /v Debugger /d "%noop%" /f %.% &taskkill /im "wuauclt.exe" /t /f %.%
193
if defined downloads_blocked sc config TrustedInstaller type= own depend= [WUTblocked] %.%
194
exit/b
195
196
:lists
197
echo %0 %*
198-
call :reg_query "%ifeo%\MoUsoCoreWorker.exe" Debugger downloads_blocked
198+
199-
rem for /f "tokens=3" %%a in ('sc qc TrustedInstaller ^| find /I "WUTblocked"') do set "downloads_blocked=%%a"
199+
200
reg add "HKLM\SOFTWARE\WUT.bat" /v NoRefresh /d "%norefresh%" /f %.%
201
reg add "%menu%\2Lists"  /v Icon /d "ieframe.dll,%toggle%" /f %.%
202
if "%norefresh%"=="Enable" (
203-
if defined downloads_blocked (
203+
204-
 reg add "%ifeo%\MoUsoCoreWorker.exe" /v Debugger /d "%noop%" /f %.%
204+
205-
 taskkill /im "MoUsoCoreWorker.exe" /t /f %.%
205+
206-
 reg add "%ifeo%\sedlauncher.exe" /v Debugger /d "%noop%" /f %.%
206+
207-
 taskkill /im "sedlauncher.exe" /t /f %.%
207+
208-
 reg add "%ifeo%\sedsvc.exe" /v Debugger /d "%noop%" /f %.%
208+
209-
 taskkill /im "sedsvc.exe" /t /f %.%
209+
210
echo %0 %*
211
call :flip SetupHost 3Upgrades
212
for %%# in (%upgrader%) do if defined block (
213
 reg delete "%ifeo%\%%#.exe" /f %.%
214
) else (
215
 reg add "%ifeo%\%%#.exe" /v Debugger /d "%noop%" /f %.% &taskkill /im "%%#.exe" /t /f %.%
216
)
217
exit/b
218
219
:installs
220
echo %0 %*
221
call :flip wuauclt 4Installs
222
for %%# in (%installer%) do if defined block (
223
 do reg delete "%ifeo%\%%#.exe" /f %.%
224
) else (
225
 reg add "%ifeo%\%%#.exe" /v Debugger /d "%SystemRoot%\WUTRefresh.bat" /f %.% &taskkill /im "%%#.exe" /t /f %.%
226
)
227
if defined block start "wut" wscript /e:JScript "%f0%" WUTRefresh
228
exit/b
229
230-
for %%a in (%upgrader%) do if defined block (
230+
231-
 reg delete "%ifeo%\%%a.exe" /f %.%
231+
232
call :reg_query "%wut%3apply" MUIVerb pending
233-
 reg add "%ifeo%\%%a.exe" /v Debugger /d "%noop%" /f %.% &taskkill /im "%%a.exe" /t /f %.%
233+
234
if defined pending if "%pending%"=="%reboot%" set "pending="
235
if defined pending (
236
 sc config TrustedInstaller type= own depend= / %.%
237
 reg add "%menu%\5Downloads"  /v Icon /d "ieframe.dll,11" /f %.%
238
 exit/b
239
)
240-
for %%a in (%installer%) do if defined block (
240+
for /f "tokens=3" %%# in ('sc qc TrustedInstaller ^| find /I "WUTblocked"') do set "blocked=%%#"
241-
 do reg delete "%ifeo%\%%a.exe" /f %.%
241+
if /i "%blocked%"=="[WUTblocked]" (set "blocked=/" &set "toggle=39") else set "blocked=[WUTblocked]" &set "toggle=38"
242
reg add "%menu%\5Downloads"  /v Icon /d "ieframe.dll,%toggle%" /f %.%
243-
 reg add "%ifeo%\%%a.exe" /v Debugger /d "%SystemRoot%\WUTRefresh.bat" /f %.% &taskkill /im "%%a.exe" /t /f %.%
243+
244
for /f "tokens=3" %%# in ('sc queryex TrustedInstaller ^| find /i "PID"') do set "pid=%#"
245
if not "%pid%"=="0" taskkill /pid %pid% /f %.%
246
sc config TrustedInstaller type= own depend= %blocked% %.%
247
if defined block start "wut" wscript /e:JScript "%f0%" WUTRefresh
248
exit/b
249
250
:service
251
echo %0 %*
252
for /f "tokens=3" %%# in ('sc qc wuauserv ^| find /I "WUTblocked"') do set "blocked=%%#"
253
if /i "%blocked%"=="rpcss[WUTblocked]" (set "blocked=rpcss" &set "toggle=39") else set "blocked=rpcss[WUTblocked]" &set "toggle=38"
254
reg add "%menu%\6Service"  /v Icon /d "ieframe.dll,%toggle%" /f %.%
255-
 for %%a in (%downloader%) do reg delete "%ifeo%\%%a.exe" /f %.%
255+
256
for /f "tokens=3" %%# in ('sc queryex wuauserv ^| find /i "PID"') do set "pid=%#"
257
if not "%pid%"=="0" taskkill /pid %pid% /f %.%
258
sc config wuauserv type= share depend= %blocked% %.%
259
if defined block start "wut" wscript /e:JScript "%f0%" WUTRefresh
260-
call :flip MoUsoCoreWorker 5Downloads
260+
261-
for %%a in (%downloader%) do if defined block (
261+
262-
 do reg delete "%ifeo%\%%a.exe" /f %.%
262+
263-
 for /f "tokens=3" %%a in ('sc queryex TrustedInstaller ^| find /i "PID"') do if not "%%a"=="0" taskkill /pid %%a /f %.%
263+
264-
 sc config TrustedInstaller type= own depend= [WUTblocked] %.%
264+
265
sc config wuauserv type= share depend= rpcss %.%
266-
 reg add "%ifeo%\%%a.exe" /v Debugger /d "%SystemRoot%\WUTRefresh.bat" /f %.% &taskkill /im "%%a.exe" /t /f %.%
266+
267
:: Remove any IFEO blocking done by past scripts
268
set eo=DiagnosticsHub.StandardCollector.Service WindowsUpdateElevatedInstaller LocationNotificationWindows InstallAgentUserBroker
269
set eo=%eo% UpdateNotificationMgr DataUsageLiveTileTask Windows10UpgraderApp WindowsActionDialog SpeechModelDownload WerFaultSecure
270
set eo=%eo% GetCurrentRollback WindowsUpdateBox Windows10Upgrade TrustedInstaller MusNotification DiagTrackRunner CompatTelRunner
271
set eo=%eo% WinREBootApp64 WinREBootApp32 UNPUXLauncher SpeechRuntime MusNotifyIcon PilotshubApp InstallAgent dstokenclean wsqmcons
272
set eo=%eo% disksnapshot osrssupdate wuapihost WaaSMedic UsoClient UNPUXHost SIHClient setupprep SetupHost osrssinst EOSNotify wusa
273
set eo=%eo% WerFault TiWorker SearchUI DWTRIG20 dusmtask dmclient appidtel wuauclt wermgr DFDWiz remsh reach HxTsr DWWIN DW20 GWX
274-
for /f "tokens=3" %%a in ('sc qc wuauserv ^| find /I "WUTblocked"') do set "blocked=%%a"
274+
for %%# in (%eo%) do reg delete "%ifeo%\%%#.exe" /f %.%
275
:: Restore notification hijacking
276
>"%SystemRoot%\WUTRefresh.bat" echo/@start "WUTRefresh" /min wscript.exe /e:JScript "%f0%" WUTRefresh
277
for %%# in (MusNotification EOSNotify) do reg add "%ifeo%\%%#.exe" /v Debugger /d "%SystemRoot%\WUTRefresh.bat" /f %.%
278-
for /f "tokens=3" %%a in ('sc queryex wuauserv ^| find /i "PID"') do set "pid=%a"
278+
279
reg delete "HKLM\SOFTWARE\WUT.bat" /v Pending /f %.%
280
:: Refresh menu
281
call :refresh repair
282
:: Open Update Diagnostic
283
start "wud" msdt.exe /id WindowsUpdateDiagnostic %.%
284
:: Open official update troubleshooter page
285
start https://support.microsoft.com/en-us/help/4027322/windows-update-troubleshooter %.%
286
exit/b
287
288
:report
289
echo %0 %*
290
call :flip wermgr 81Report
291
for %%# in (%reporter%) do if defined block ( reg delete "%ifeo%\%%#.exe" /f %.% ) else (
292
 reg add "%ifeo%\%%#.exe" /v Debugger /d "%noop%" /f %.% &taskkill /im "%%#.exe" /t /f %.%
293
)
294
exit/b
295
296-
set eo=%eo% MoUsoCoreWorker sedlauncher sedsvc
296+
297-
for %%a in (%eo%) do reg delete "%ifeo%\%%a.exe" /f %.%
297+
298
call :flip SpeechRuntime 82Speech
299
for %%# in (%speecher%) do if defined block ( reg delete "%ifeo%\%%#.exe" /f %.% ) else (
300-
for %%a in (MusNotification EOSNotify) do reg add "%ifeo%\%%a.exe" /v Debugger /d "%SystemRoot%\WUTRefresh.bat" /f %.%
300+
 reg add "%ifeo%\%%#.exe" /v Debugger /d "%noop%" /f %.% &taskkill /im "%%#.exe" /t /f %.%
301
)
302
exit/b
303
304
:search
305
echo %0 %*
306
call :flip SearchUI 83Search
307
for %%# in (%searcher%) do if defined block ( reg delete "%ifeo%\%%#.exe" /f %.% ) else (
308
 reg add "%ifeo%\%%#.exe" /v Debugger /d "%noop%" /f %.% &taskkill /im "%%#.exe" /t /f %.%
309
)
310
exit/b
311
312
:defender
313
echo %0 %*
314-
for %%a in (%reporter%) do if defined block ( reg delete "%ifeo%\%%a.exe" /f %.% ) else (
314+
315-
 reg add "%ifeo%\%%a.exe" /v Debugger /d "%noop%" /f %.% &taskkill /im "%%a.exe" /t /f %.%
315+
316
set "s12=Set-MpPreference -DisableBehaviorMonitoring $t"
317
set "s13=Set-MpPreference -DisableIOAVProtection $t"
318
set "s14=write-host $toggle"
319
for /f "delims=" %%# in ('call powershell.exe -c "%s10%;%s11%;%s12%;%s13%;%s14%;"') do set "toggle=%%#"
320
reg add "%menu%\84Defender" /v Icon /d "ieframe.dll,%toggle%" /f %.%
321
exit/b
322-
for %%a in (%speecher%) do if defined block ( reg delete "%ifeo%\%%a.exe" /f %.% ) else (
322+
323-
 reg add "%ifeo%\%%a.exe" /v Debugger /d "%noop%" /f %.% &taskkill /im "%%a.exe" /t /f %.%
323+
324
tasklist /FI "IMAGENAME eq MpCmdRun.exe" | find ".exe" %.%
325
if not errorlevel 1 exit/b
326
pushd %ProgramFiles%\Windows Defender
327
call MpCmdRun.exe -removedefinitions -dynamicsignatures
328
call MpCmdRun.exe -SignatureUpdate -MMPC
329
exit/b
330-
for %%a in (%searcher%) do if defined block ( reg delete "%ifeo%\%%a.exe" /f %.% ) else (
330+
331-
 reg add "%ifeo%\%%a.exe" /v Debugger /d "%noop%" /f %.% &taskkill /im "%%a.exe" /t /f %.%
331+
332
echo %0 %*
333
pushd %SystemRoot%
334
if /i "%~f0"=="%f0%" (set "initial_setup=") else copy /y "%~f0" "%f0%" %.%
335
:: Create WUTUndo for emergencies
336
 >WUTUndo.bat echo/pushd %%~dp0system32\config
337
>>WUTUndo.bat echo/reg load HKLM\WUTUndo1 SOFTWARE
338
>>WUTUndo.bat echo/set "koff=HKLM\WUTUndo1\Microsoft\Windows NT\CurrentVersion\Image File Execution Options" ^&set "kon=%ifeo%"
339
>>WUTUndo.bat echo/for %%%%B in (%exe%) do for %%%%K in ("%%koff%%" "%%kon%%") do reg delete "%%%%~K\%%%%B.exe" /f 2^>nul
340
>>WUTUndo.bat echo/reg unload HKLM\WUTUndo1
341
>>WUTUndo.bat echo/reg load HKLM\WUTUndo2 SYSTEM
342-
for /f "delims=" %%a in ('call powershell.exe -c "%s10%;%s11%;%s12%;%s13%;%s14%;"') do set "toggle=%%a"
342+
343
>>WUTUndo.bat echo/ reg delete "HKLM\%%%%~K\ControlSet001\Services\TrustedInstaller" /v DependOnService /f 2^>nul
344
>>WUTUndo.bat echo/ reg delete "HKLM\%%%%~K\CurrentControlSet\Services\TrustedInstaller" /v DependOnService /f 2^>nul
345
>>WUTUndo.bat echo/)
346
>>WUTUndo.bat echo/reg unload HKLM\WUTUndo2
347
:: Create WUTRefresh to hijack update notifications and refresh context menu in addition to preventing forced reboots
348
>WUTRefresh.bat echo/@start "WUTRefresh" /min wscript.exe /e:JScript "%f0%" WUTRefresh
349
:: Create tasks to run context menu entries with proper access and no output window
350
start "WUT" wscript /e:JScript "%~f0" cmd "call `%~f0` setup_schtasks"
351
:: WUT options
352
for %%# in (NoBlock NoRefresh) do reg add "HKLM\SOFTWARE\WUT.bat" /v %%# /d "Enable" /f %.%
353
call :toggle blocking
354
exit/b
355
356
:setup_schtasks - no stalling separate process
357
set "strun=wscript.exe /e:JScript \"%f0%\" run%window%"
358
for %%t in (refresh lists upgrades installs downloads service repair report speech search defender toggle renew remove) do (
359
 schtasks /create /ru "%username%" /sc once /tn "WUT\%%t" /tr "%strun% %%t" /st "00:00:00" /it /rl highest /f %.%
360
)
361
for %%t in (hide unhide apply) do for /l %%n in (101,1,116) do (
362
 schtasks /create /ru "%username%" /sc once /tn "WUT\%%t\%%n" /tr "%strun% %%t %%n" /st "00:00:00" /it /rl highest /f %.%
363
)
364
exit/b
365
366
:renew
367
echo %0 %*
368
echo Renewing from internet - old version saved as %SystemRoot%\WUT.old
369
pushd %SystemRoot%
370
if exist WUT.new del /f /q WUT.new %.%
371
call wscript /e:JScript "%~f0" renew "https://pastebin.com/raw/gNsLEWJe" "%SystemRoot%\WUT.new"
372
if exist WUT.new copy /y "%f0%" WUT.old %.% &copy /y WUT.new "%f0%" %.% &del /f /q WUT.new %.%
373
start "WUT" "%f0%" %.%
374
exit
375-
for %%a in (NoBlock NoRefresh) do reg add "HKLM\SOFTWARE\WUT.bat" /v %%a /d "Enable" /f %.%
375+
376
:remove
377
echo %0 %*
378
for %%# in (NoBlock NoRefresh) do reg add "HKLM\SOFTWARE\WUT.bat" /v %%# /d "Disable" /f %.%
379
call :toggle off
380
reg delete "HKLM\SOFTWARE\WUT.bat" /f %.%
381
for %%# in ("" "0pending" "1hide" "2unhide" "3apply") do reg delete "%wut%%%~#" /f %.%
382
for %%t in (refresh lists upgrades installs downloads service repair report speech search defender toggle renew remove) do (
383
 schtasks /delete /tn "WUT\%%t" /f %.%
384
)
385
for %%t in (hide unhide apply) do for /l %%n in (101,1,116) do schtasks /delete /tn "WUT\%%t\%%n" /f %.%
386
for %%t in (hide unhide apply) do schtasks /delete /tn "WUT\%%t" /f %.%
387
schtasks /delete /tn "WUT" /f %.%
388
sc config wuauserv type= share depend= rpcss %.%
389
sc config TrustedInstaller type= own depend= / %.%
390
pushd %SystemRoot%
391
del /f /q WUT.bat WUT.old DefenderManualUpdate.bat WUTRefresh.bat WUTUndo.bat "%f0%" %.%
392
exit/b
393
394
:reg_query %1:KeyName %2:ValueName %3:OutputVariable %4:other_options[example: "/t REG_DWORD"]
395
setlocal & for /f "skip=2 delims=" %%s in ('reg query "%~1" /v "%~2" /z 2^>nul') do set "rq=%%s" & call set "rv=%%rq:*)    =%%"
396
endlocal & set "%~3=%rv%" & exit/b &rem                                         AveYo: call :reg_query "HKCU\MyKey" "MyValue" MyVar
397
398
::---------------------------------------------------------------------------------------------------------------------------------
399
:JScript_functions                                                                 AveYo: Switch syntax highlighter to 'javascript'
400
::-------------------------------------------------------------------------------------------------------------------------------*/
401-
for %%a in (NoBlock NoRefresh) do reg add "HKLM\SOFTWARE\WUT.bat" /v %%a /d "Disable" /f %.%
401+
402
function sex(exe,args){WSH.CreateObject('Shell.Application').ShellExecute(exe,args,'','',0);}; function reg(s){ sex('reg.exe',s); }
403
404-
for %%a in ("" "0pending" "1hide" "2unhide" "3apply") do reg delete "%wut%%%~a" /f %.%
404+
405
if (run=='cmd') sex('cmd','/c '+args.replace(/`/g,'"'));
406
407
// Context menu entries trigger - elevated with no popups
408
if (run=='schtasks') sex('SCHTASKS.EXE','/Run /TN '+args);
409
410
// Shift to CMD if loaded by WScript - pass arguments, prevent loop, run as admin at setup, hide window at context-menu
411
function cmd(adm,win){WSH.CreateObject('Shell.Application').ShellExecute('cmd','/c call "'+f0+'" shift "'+f0+'"'+args,'',adm,win);}
412
if (run=='run') cmd('',1); if (run=='runhide') cmd('',0); if (run=='runas') cmd('runas',1); if (run=='runashide') cmd('runas',0);
413
414
if (run=='renew') {
415
  // renew script over internet
416
  try{
417
  downloader=WSH.CreateObject("WinHttp.WinHttpRequest.5.1");
418
  if (downloader===null) downloader=WSH.CreateObject("WinHttp.WinHttpRequest");
419
  if (downloader===null) downloader=WSH.CreateObject("MSXML2.ServerXMLHTTP");
420
  if (downloader===null) downloader=WSH.CreateObject("Microsoft.XMLHTTP");
421
  downloader.Open("GET",WSH.Arguments(1),false); downloader.Send(); oASI=downloader.ResponseBody(); downloader=undefined;
422
  oASO=WSH.CreateObject("ADODB.Stream"); oASO.type=1; oASO.Mode=3; oASO.Open; oASO.Write(oASI); oASI=undefined;
423
  oASO.SaveToFile(WSH.Arguments(2)); oASO.Close();
424
  }catch(e){} // supress all errors since we're working with com objects
425
}
426
427
// WUT Hide/Unhide/Apply lists
428
if (run=='WUTRefresh' || run=='hide' || run=='unhide' || run=='apply') {
429
  SRP=GetObject("winmgmts:StdRegProv"); pending=SRP.GetStringValue(2147483650,'SOFTWARE\\WUT.bat','Pending');
430
  if (pending===0) WSH.quit(); else SRP.SetStringValue(2147483650,'SOFTWARE\\WUT.bat','Pending','yes'); // prevent instances
431
  k='HKCR\\DesktopBackground\\shell\\WUT'; hk=k+'1hide'; uk=k+'2unhide'; ik=k+'3apply'; pk=k+'0pending';// short list keys
432
  reg('delete "'+hk+'" /f');reg('delete "'+uk+'" /f');reg('delete "'+ik+'" /f'); reg('add "'+pk+'" /v MUIVerb /d "Pending.." /f');
433
  reg('add "'+pk+'" /v SubCommands /d "" /f'); reg('add "'+pk+'" /v Icon /d "ieframe.dll,11" /f');
434
  // Check for updates
435
  count=0; wuthide=[]; wutunhide=[];
436
  try{
437
  session=WSH.CreateObject("Microsoft.Update.Session"); reboot=WSH.CreateObject("Microsoft.Update.SystemInfo").RebootRequired;
438
  searcher=session.CreateUpdateSearcher();
439
  sresult=searcher.Search("IsInstalled=0"); Updatelist=sresult.Updates; count=sresult.Updates.Count;
440
  for(i=0;i<count;i++) {
441
    itemTitle=Updatelist.Item(i).Title;
442
    minsize=Updatelist.Item(i).MinDownloadSize; maxsize=Updatelist.Item(i).MaxDownloadSize; wutsize='';
443
    if (maxsize > 1073741824) wutsize=' ['+Math.round(minsize/10737418.24)/100+' - '+Math.round(maxsize/10737418.24)/100+'GB]';
444
    else if (maxsize > 1048576) wutsize=' ['+Math.round(minsize/10485.76)/100+' - '+Math.round(maxsize/10485.76)/100+'MB]';
445
    else if (maxsize > 1024) wutsize=' ['+Math.round(minsize/10.24)/100+' - '+Math.round(maxsize/10.24)/100+'KB]';
446
    else if (maxsize > 0) wutsize=' ['+(minsize)+' - '+(maxsize)+'B]';
447
    wutTitle=Updatelist.Item(i).Title + wutsize;
448
    if (run=='apply' && WSH.Arguments(1).indexOf(itemTitle) > -1) {
449
      // Add matching entry to UpdateColl
450
      UpdateColl=WSH.CreateObject("Microsoft.Update.UpdateColl"); UpdateColl.Add(Updatelist.Item(i));
451
      // Download update
452
      downloader=session.CreateUpdateDownloader(); downloader.Updates=UpdateColl; dresult=downloader.Download();
453
      if (dresult.ResultCode==2) {
454
        // Unblock apply
455
        sex('sc','config TrustedInstaller type= own depend= /');
456
        KeyPath='SOFTWARE\\Microsoft\\Windows NT\\CurrentVersion\\Image File Execution Options\\wuauclt.exe';
457
        SRP.DeleteKey(2147483650,KeyPath);
458
        WSH.Sleep(1000);
459
        //Apply update
460
        installer=session.CreateUpdateInstaller(); installer.Updates=UpdateColl; iresult=installer.Install();
461
        if (iresult.ResultCode==2) continue;
462
      }
463
    }
464
    // hide and unhide are very simple bool flip compared to apply
465
    if (run=='hide' && WSH.Arguments(1).indexOf(itemTitle) > -1) {
466
      Updatelist.Item(i).IsHidden=true; wutunhide.push(wutTitle); continue;
467
    }
468
    if (run=='unhide' && WSH.Arguments(1).indexOf(itemTitle) > -1) {
469
      Updatelist.Item(i).IsHidden=false; wuthide.push(wutTitle); continue;
470
    }
471
    // Trigger :update_defender to manually refresh definitions from MMPC
472
    if (Updatelist.Item(i).IsHidden===false && itemTitle.indexOf('(Definition') > -1) {
473
      sex('cmd','/c call "'+f0+'" update_defender');
474
    }
475
    // Sorting lists
476
    if (Updatelist.Item(i).IsHidden) wutunhide.push(wutTitle); else wuthide.push(wutTitle);
477
  }
478
  // Generate Hide context menu
479-
        KeyPath='SOFTWARE\\Microsoft\\Windows NT\\CurrentVersion\\Image File Execution Options\\';
479+
480-
        SRP.DeleteKey(2147483650,KeyPath+'wuauclt.exe');
480+
481-
        SRP.DeleteKey(2147483650,KeyPath+'MoUsoCoreWorker.exe');
481+
482-
        SRP.DeleteKey(2147483650,KeyPath+'sedlauncher.exe');
482+
483-
        SRP.DeleteKey(2147483650,KeyPath+'sedsvc.exe');
483+
484
      reg('add "'+hk+'\\shell\\'+i+'" /v MUIVerb /d "'+wuthide[i-101]+'" /f');
485
      reg('add "'+hk+'\\shell\\'+i+'\\command" /ve /d "wscript.exe /e:JScript \\"'+f0+'\\" schtasks WUT\\hide\\'+i+'" /f');
486
    }
487
  }
488
  // Generate Unhide context menu
489
  if (wutunhide.length>0){
490
    reg('add "'+uk+'" /v MUIVerb /d "Unhide '+"\t"+wutunhide.length+'" /f');
491
    reg('add "'+uk+'" /v Icon /d "ieframe.dll,42" /f');
492
    reg('add "'+uk+'" /v SubCommands /d "" /f');
493
    for(i=101,n=wutunhide.length+101;i<n;i++) {
494
      reg('add "'+uk+'\\shell\\'+i+'" /v MUIVerb /d "'+wutunhide[i-101]+'" /f');
495
      reg('add "'+uk+'\\shell\\'+i+'\\command" /ve /d "wscript.exe /e:JScript \\"'+f0+'\\" schtasks WUT\\unhide\\'+i+'" /f');
496
    }
497
  }
498
  // Generate Apply context menu
499
  if (wuthide.length>0){
500
    reg('add "'+ik+'" /v MUIVerb /d "Apply '+"\t"+((reboot) ? 'must reboot ' : wuthide.length)+'" /f');
501
    reg('add "'+ik+'" /v Icon /d "ieframe.dll,42" /f');
502
    reg('add "'+ik+'" /v SubCommands /d "" /f');
503
    for(i=101,n=wuthide.length+101;i<n;i++) {
504
      reg('add "'+ik+'\\shell\\'+i+'" /v MUIVerb /d "'+wuthide[i-101]+'" /f');
505
      reg('add "'+ik+'\\shell\\'+i+'\\command" /ve /d "wscript.exe /e:JScript \\"'+f0+'\\" schtasks WUT\\apply\\'+i+'" /f');
506
    }
507
  }
508
  }catch(e){} // supress all errors since we're working with com objects
509
  reg('delete "'+pk+'" /f'); SRP.DeleteValue(2147483650,'SOFTWARE\\WUT.bat','Pending'); // Remove Pending.. temporary entry
510
}
511
//