-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDefenderToggle.bat
More file actions
224 lines (203 loc) · 12.1 KB
/
Copy pathDefenderToggle.bat
File metadata and controls
224 lines (203 loc) · 12.1 KB
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
@echo off
title Windows Defender Toggle v3
chcp 65001 >nul 2>&1
color 0A
:: ===== ADMIN CHECK - Auto Elevation =====
net session >nul 2>&1
if %errorLevel% neq 0 (
powershell -Command "Start-Process '%~f0' -Verb RunAs"
exit /b
)
:MENU
cls
echo.
echo ╔════════════════════════════════════════════╗
echo ║ WINDOWS DEFENDER TOGGLE v3 ║
echo ╠════════════════════════════════════════════╣
echo ║ ║
echo ║ [1] FULLY DISABLE (Requires reboot) ║
echo ║ [2] FULLY ENABLE (Requires reboot) ║
echo ║ [3] Disable Tamper Protection ║
echo ║ [4] Status Report ║
echo ║ [5] Exit ║
echo ║ ║
echo ╚════════════════════════════════════════════╝
echo.
powershell -NoProfile -Command ^
"$s = Get-MpComputerStatus; " ^
"Write-Host ' Real-Time Protection : ' -NoNewline; " ^
"if ($s.RealTimeProtectionEnabled) { Write-Host 'ON' -ForegroundColor Green } else { Write-Host 'OFF' -ForegroundColor Red }; " ^
"Write-Host ' Tamper Protection : ' -NoNewline; " ^
"if ($s.IsTamperProtected) { Write-Host 'ON - USE MENU 3 FIRST!' -ForegroundColor Yellow } else { Write-Host 'OFF' -ForegroundColor Green }; " ^
"Write-Host ' Antivirus Service : ' -NoNewline; " ^
"if ($s.AntivirusEnabled) { Write-Host 'ON' -ForegroundColor Green } else { Write-Host 'OFF' -ForegroundColor Red };"
echo.
set /p choice=" Your choice (1-5): "
if "%choice%"=="1" goto DISABLE
if "%choice%"=="2" goto ENABLE
if "%choice%"=="3" goto TAMPER
if "%choice%"=="4" goto STATUS
if "%choice%"=="5" exit /b 0
goto MENU
:TAMPER
cls
echo.
echo TAMPER PROTECTION DISABLE GUIDE
echo ════════════════════════════════════════════
echo.
echo 1. Scroll down on the opened settings page
echo 2. Find "Tamper Protection"
echo 3. Toggle it OFF
echo 4. Click YES on the UAC prompt
echo 5. Come back here and press ENTER
echo.
echo ════════════════════════════════════════════
echo.
start "" "windowsdefender://threatsettings"
echo Settings page opened. Disable Tamper Protection, then press ENTER.
pause
goto MENU
:DISABLE
cls
echo.
echo DISABLING DEFENDER...
echo ════════════════════════════════════════════
echo.
:: Tamper Protection check
powershell -NoProfile -Command ^
"if ((Get-MpComputerStatus).IsTamperProtected) { " ^
" Write-Host ' [X] TAMPER PROTECTION IS ON!' -ForegroundColor Red; " ^
" Write-Host ' [!] Disable it first using menu 3!' -ForegroundColor Yellow; " ^
" exit 1 " ^
"}"
if %errorLevel% neq 0 (
echo.
pause
goto MENU
)
echo [1/5] Disabling all protections via PowerShell...
powershell -NoProfile -Command ^
"Set-MpPreference -DisableRealtimeMonitoring $true; " ^
"Set-MpPreference -DisableIOAVProtection $true; " ^
"Set-MpPreference -DisableBehaviorMonitoring $true; " ^
"Set-MpPreference -DisableBlockAtFirstSeen $true; " ^
"Set-MpPreference -DisableScriptScanning $true; " ^
"Write-Host ' Done.' -ForegroundColor Green"
echo [2/5] Writing Group Policy registry keys...
reg add "HKLM\SOFTWARE\Policies\Microsoft\Windows Defender\Real-Time Protection" /v DisableRealtimeMonitoring /t REG_DWORD /d 1 /f >nul 2>&1
reg add "HKLM\SOFTWARE\Policies\Microsoft\Windows Defender\Real-Time Protection" /v DisableBehaviorMonitoring /t REG_DWORD /d 1 /f >nul 2>&1
reg add "HKLM\SOFTWARE\Policies\Microsoft\Windows Defender\Real-Time Protection" /v DisableIOAVProtection /t REG_DWORD /d 1 /f >nul 2>&1
reg add "HKLM\SOFTWARE\Policies\Microsoft\Windows Defender\Real-Time Protection" /v DisableOnAccessProtection /t REG_DWORD /d 1 /f >nul 2>&1
reg add "HKLM\SOFTWARE\Policies\Microsoft\Windows Defender\Real-Time Protection" /v DisableScanOnRealtimeEnable /t REG_DWORD /d 1 /f >nul 2>&1
echo Done.
echo [3/5] Disabling Defender service...
reg add "HKLM\SOFTWARE\Policies\Microsoft\Windows Defender" /v DisableAntiSpyware /t REG_DWORD /d 1 /f >nul 2>&1
reg add "HKLM\SOFTWARE\Policies\Microsoft\Windows Defender" /v DisableAntiVirus /t REG_DWORD /d 1 /f >nul 2>&1
reg add "HKLM\SYSTEM\CurrentControlSet\Services\WinDefend" /v Start /t REG_DWORD /d 4 /f >nul 2>&1
reg add "HKLM\SYSTEM\CurrentControlSet\Services\SecurityHealthService" /v Start /t REG_DWORD /d 4 /f >nul 2>&1
echo Done.
echo [4/5] Disabling cloud protection...
reg add "HKLM\SOFTWARE\Policies\Microsoft\Windows Defender\Spynet" /v SpynetReporting /t REG_DWORD /d 0 /f >nul 2>&1
reg add "HKLM\SOFTWARE\Policies\Microsoft\Windows Defender\Spynet" /v SubmitSamplesConsent /t REG_DWORD /d 2 /f >nul 2>&1
reg add "HKLM\SOFTWARE\Policies\Microsoft\Windows Defender Security Center\Notifications" /v DisableNotifications /t REG_DWORD /d 1 /f >nul 2>&1
reg add "HKLM\SOFTWARE\Policies\Microsoft\Windows Defender Security Center\Systray" /v HideSystray /t REG_DWORD /d 1 /f >nul 2>&1
echo Done.
echo [5/5] Disabling scheduled tasks...
schtasks /Change /TN "Microsoft\Windows\Windows Defender\Windows Defender Cache Maintenance" /Disable >nul 2>&1
schtasks /Change /TN "Microsoft\Windows\Windows Defender\Windows Defender Cleanup" /Disable >nul 2>&1
schtasks /Change /TN "Microsoft\Windows\Windows Defender\Windows Defender Scheduled Scan" /Disable >nul 2>&1
schtasks /Change /TN "Microsoft\Windows\Windows Defender\Windows Defender Verification" /Disable >nul 2>&1
echo Done.
echo.
echo ════════════════════════════════════════════
powershell -NoProfile -Command "Write-Host ' [OK] DEFENDER FULLY DISABLED!' -ForegroundColor Green"
echo A reboot is required for all changes.
echo ════════════════════════════════════════════
echo.
set /p reboot=" Reboot now? (Y/N): "
if /i "%reboot%"=="Y" shutdown /r /t 5 /c "Defender Toggle - Rebooting..."
goto MENU
:ENABLE
cls
echo.
echo ENABLING DEFENDER...
echo ════════════════════════════════════════════
echo.
echo [1/5] Enabling all protections via PowerShell...
powershell -NoProfile -Command ^
"Set-MpPreference -DisableRealtimeMonitoring $false; " ^
"Set-MpPreference -DisableIOAVProtection $false; " ^
"Set-MpPreference -DisableBehaviorMonitoring $false; " ^
"Set-MpPreference -DisableBlockAtFirstSeen $false; " ^
"Set-MpPreference -DisableScriptScanning $false; " ^
"Write-Host ' Done.' -ForegroundColor Green"
echo [2/5] Removing Group Policy overrides...
reg delete "HKLM\SOFTWARE\Policies\Microsoft\Windows Defender\Real-Time Protection" /f >nul 2>&1
echo Done.
echo [3/5] Enabling Defender service...
reg delete "HKLM\SOFTWARE\Policies\Microsoft\Windows Defender" /v DisableAntiSpyware /f >nul 2>&1
reg delete "HKLM\SOFTWARE\Policies\Microsoft\Windows Defender" /v DisableAntiVirus /f >nul 2>&1
reg add "HKLM\SYSTEM\CurrentControlSet\Services\WinDefend" /v Start /t REG_DWORD /d 2 /f >nul 2>&1
reg add "HKLM\SYSTEM\CurrentControlSet\Services\SecurityHealthService" /v Start /t REG_DWORD /d 2 /f >nul 2>&1
echo Done.
echo [4/5] Enabling cloud protection...
reg delete "HKLM\SOFTWARE\Policies\Microsoft\Windows Defender\Spynet" /f >nul 2>&1
reg delete "HKLM\SOFTWARE\Policies\Microsoft\Windows Defender Security Center\Notifications" /f >nul 2>&1
reg delete "HKLM\SOFTWARE\Policies\Microsoft\Windows Defender Security Center\Systray" /f >nul 2>&1
echo Done.
echo [5/5] Enabling scheduled tasks...
schtasks /Change /TN "Microsoft\Windows\Windows Defender\Windows Defender Cache Maintenance" /Enable >nul 2>&1
schtasks /Change /TN "Microsoft\Windows\Windows Defender\Windows Defender Cleanup" /Enable >nul 2>&1
schtasks /Change /TN "Microsoft\Windows\Windows Defender\Windows Defender Scheduled Scan" /Enable >nul 2>&1
schtasks /Change /TN "Microsoft\Windows\Windows Defender\Windows Defender Verification" /Enable >nul 2>&1
echo Done.
echo.
echo ════════════════════════════════════════════
powershell -NoProfile -Command "Write-Host ' [OK] DEFENDER FULLY ENABLED!' -ForegroundColor Green"
echo A reboot is required for all changes.
echo ════════════════════════════════════════════
echo.
set /p reboot=" Reboot now? (Y/N): "
if /i "%reboot%"=="Y" shutdown /r /t 5 /c "Defender Toggle - Rebooting..."
goto MENU
:STATUS
cls
echo.
echo DETAILED STATUS REPORT
echo ════════════════════════════════════════════
echo.
powershell -NoProfile -Command ^
"$s = Get-MpComputerStatus; " ^
"Write-Host ' --- Defender Status ---' -ForegroundColor Cyan; " ^
"Write-Host ' Real-Time Protection : ' -NoNewline; " ^
"if ($s.RealTimeProtectionEnabled) { Write-Host 'ON' -ForegroundColor Green } else { Write-Host 'OFF' -ForegroundColor Red }; " ^
"Write-Host ' Tamper Protection : ' -NoNewline; " ^
"if ($s.IsTamperProtected) { Write-Host 'ON' -ForegroundColor Yellow } else { Write-Host 'OFF' -ForegroundColor Green }; " ^
"Write-Host ' Antivirus : ' -NoNewline; " ^
"if ($s.AntivirusEnabled) { Write-Host 'ON' -ForegroundColor Green } else { Write-Host 'OFF' -ForegroundColor Red }; " ^
"Write-Host ' Anti-Spyware : ' -NoNewline; " ^
"if ($s.AntispywareEnabled) { Write-Host 'ON' -ForegroundColor Green } else { Write-Host 'OFF' -ForegroundColor Red }; " ^
"Write-Host ' Behavior Monitoring : ' -NoNewline; " ^
"if ($s.BehaviorMonitorEnabled) { Write-Host 'ON' -ForegroundColor Green } else { Write-Host 'OFF' -ForegroundColor Red }; " ^
"Write-Host ' IOAV Protection : ' -NoNewline; " ^
"if ($s.IoavProtectionEnabled) { Write-Host 'ON' -ForegroundColor Green } else { Write-Host 'OFF' -ForegroundColor Red }; " ^
"Write-Host ''; " ^
"Write-Host ' --- Registry Status ---' -ForegroundColor Cyan; " ^
"Write-Host ' DisableRealtimeMonitor : ' -NoNewline; " ^
"$v1 = (Get-ItemProperty 'HKLM:\SOFTWARE\Policies\Microsoft\Windows Defender\Real-Time Protection' -Name DisableRealtimeMonitoring -EA SilentlyContinue).DisableRealtimeMonitoring; " ^
"if ($v1 -eq 1) { Write-Host 'DISABLED' -ForegroundColor Red } else { Write-Host 'Not set / Enabled' -ForegroundColor Green }; " ^
"Write-Host ' DisableAntiSpyware : ' -NoNewline; " ^
"$v2 = (Get-ItemProperty 'HKLM:\SOFTWARE\Policies\Microsoft\Windows Defender' -Name DisableAntiSpyware -EA SilentlyContinue).DisableAntiSpyware; " ^
"if ($v2 -eq 1) { Write-Host 'DISABLED' -ForegroundColor Red } else { Write-Host 'Not set / Enabled' -ForegroundColor Green }; " ^
"Write-Host ' WinDefend Service : ' -NoNewline; " ^
"$svc = (Get-ItemProperty 'HKLM:\SYSTEM\CurrentControlSet\Services\WinDefend' -Name Start -EA SilentlyContinue).Start; " ^
"switch ($svc) { 2 { Write-Host 'Automatic (Normal)' -ForegroundColor Green } 3 { Write-Host 'Manual' -ForegroundColor Yellow } 4 { Write-Host 'Disabled' -ForegroundColor Red } default { Write-Host $svc } }; " ^
"Write-Host ''; " ^
"Write-Host ' --- Service Status ---' -ForegroundColor Cyan; " ^
"$wds = Get-Service WinDefend -EA SilentlyContinue; " ^
"Write-Host (' WinDefend : ' + $wds.Status); " ^
"$shs = Get-Service SecurityHealthService -EA SilentlyContinue; " ^
"Write-Host (' SecurityHealthService : ' + $shs.Status);"
echo.
pause
goto MENU