|
@echo off |
|
title Complete Windows Defender Restore |
|
NET SESSION >nul 2>&1 |
|
IF %ERRORLEVEL% NEQ 0 (echo Run as Admin! && pause && exit /b 1) |
|
|
|
echo Restoring Windows Defender to default state... |
|
|
|
REM === Remove ALL Group Policy keys we added === |
|
reg delete "HKLM\SOFTWARE\Policies\Microsoft\Windows Defender" /f 2>nul |
|
reg delete "HKLM\SOFTWARE\Policies\Microsoft\Windows Defender\Real-Time Protection" /f 2>nul |
|
reg delete "HKLM\SOFTWARE\Policies\Microsoft\Windows Defender Security Center" /f 2>nul |
|
|
|
REM === Remove direct registry modifications === |
|
reg delete "HKLM\SOFTWARE\Microsoft\Windows Defender\Real-Time Protection" /v "DisableRealtimeMonitoring" /f 2>nul |
|
reg delete "HKLM\SOFTWARE\Microsoft\Windows Defender\Features" /v "TamperProtection" /f 2>nul |
|
reg delete "HKLM\SOFTWARE\Microsoft\Windows Defender\Features" /v "TamperProtectionSource" /f 2>nul |
|
|
|
REM === Remove notification disables === |
|
reg delete "HKCU\SOFTWARE\Microsoft\Windows\CurrentVersion\Notifications\Settings\Windows.SystemToast.SecurityAndMaintenance" /v "Enabled" /f 2>nul |
|
|
|
REM === Re-enable all protections via PowerShell === |
|
echo Re-enabling all protections... |
|
|
|
PowerShell -ExecutionPolicy Bypass -Command "Set-MpPreference -DisableRealtimeMonitoring $false" 2>nul |
|
PowerShell -ExecutionPolicy Bypass -Command "Set-MpPreference -DisableBehaviorMonitoring $false" 2>nul |
|
PowerShell -ExecutionPolicy Bypass -Command "Set-MpPreference -DisableIOAVProtection $false" 2>nul |
|
PowerShell -ExecutionPolicy Bypass -Command "Set-MpPreference -DisableScriptScanning $false" 2>nul |
|
PowerShell -ExecutionPolicy Bypass -Command "Set-MpPreference -DisableBlockAtFirstSeen $false" 2>nul |
|
PowerShell -ExecutionPolicy Bypass -Command "Set-MpPreference -DisableIntrusionPreventionSystem $false" 2>nul |
|
PowerShell -ExecutionPolicy Bypass -Command "Set-MpPreference -DisableArchiveScanning $false" 2>nul |
|
|
|
REM === Re-enable Cloud Protection (MAPSReporting) === |
|
PowerShell -ExecutionPolicy Bypass -Command "Set-MpPreference -MAPSReporting 2" 2>nul |
|
|
|
REM === Re-enable Automatic Sample Submission === |
|
PowerShell -ExecutionPolicy Bypass -Command "Set-MpPreference -SubmitSamplesConsent 1" 2>nul |
|
|
|
REM === Re-enable PUA Protection === |
|
PowerShell -ExecutionPolicy Bypass -Command "Set-MpPreference -PUAProtection 1" 2>nul |
|
|
|
REM === Re-enable services === |
|
sc config WinDefend start=auto 2>nul |
|
sc config WdNisSvc start=auto 2>nul |
|
sc config SecurityHealthService start=auto 2>nul |
|
|
|
sc start WinDefend 2>nul |
|
sc start WdNisSvc 2>nul |
|
sc start SecurityHealthService 2>nul |
|
|
|
REM === Update Group Policy === |
|
gpupdate /force >nul 2>&1 |
|
|
|
echo. |
|
echo ===== FINAL STATUS ===== |
|
PowerShell -Command "Get-MpComputerStatus | Select-Object RealTimeProtectionEnabled, AntivirusEnabled, AntispywareEnabled, BehaviorMonitorEnabled, IoavProtectionEnabled, OnAccessProtectionEnabled, IsTamperProtected, @{Name='CloudProtection';Expression={$_.MAPSReporting}}, @{Name='SampleSubmission';Expression={$_.SubmitSamplesConsent}}" |
|
|
|
echo. |
|
echo All registry modifications removed and protections restored! |
|
echo. |
|
echo Cloud-Delivered Protection: Should show 2 (Advanced) |
|
echo Automatic Sample Submission: Should show 1 (Send safe samples) |
|
echo. |
|
echo REBOOT if anything shows False/0 |
|
pause |