MOVED SOLUTION HERE: Windows Defender Auto Toggle Does somebody know how to create a "toggle" script, (either a .bat or .ps1) for these 2 commands? Code: DefenderControl.exe /D DefenderControl.exe /E Edit: They're command line switches for Defender Control So if Windows Defender is enabled and I run the script, Windows Defender gets disabled. And vice versa Thanks
I had something kinda similar for the registry override key that I use. You're welcome to do whatever you want with it. Code: @echo off title Disable/Enable Windows Defender color 1f :Begin UAC check and Auto-Elevate Permissions :------------------------------------- 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: echo Requesting Administrative Privileges... echo Press YES in UAC Prompt to Continue echo: 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" :-------------------------------------- :Check the key: (reg query "HKEY_LOCAL_MACHINE\SOFTWARE\Policies\Microsoft\Windows Defender" /v "DisableAntiSpyware"|find /i "0x1")>NUL 2>NUL if %errorlevel% neq 0 GOTO :KEYOFF :KEYON echo ============================================================ echo Windows Defender currently disabled. echo Would you like to re-enable it? (Y/N) echo ============================================================ echo. choice /c yn /n If %ERRORLEVEL% NEQ 1 GOTO :QUIT Echo Changing Registry key REG ADD "HKEY_LOCAL_MACHINE\SOFTWARE\Policies\Microsoft\Windows Defender" /v "DisableAntiSpyware" /D 0 /T REG_DWORD /F>NUL 2>NUL IF %ERRORLEVEL% NEQ 0 GOTO :ERROR Echo. Echo Windows Defender enabled Echo. goto :QUIT :KEYOFF echo ============================================================ echo Windows Defender is currently enabled. echo Would you like to disable it? (Y/N) echo ============================================================ echo. choice /c yn /n If %ERRORLEVEL% NEQ 1 GOTO :QUIT Echo Changing Registry key REG ADD "HKEY_LOCAL_MACHINE\SOFTWARE\Policies\Microsoft\Windows Defender" /v "DisableAntiSpyware" /D 1 /T REG_DWORD /F>NUL 2>NUL IF %ERRORLEVEL% NEQ 0 GOTO :ERROR Echo. Echo Windows Defender disabled Echo. goto :QUIT :QUIT echo ============================================================ echo Press any key to exit... echo ============================================================ pause>NUL goto :EOF :ERROR echo ============================================================ echo The script ran into an unexpected error setting reg key. echo Press any key to exit... echo ============================================================ pause>NUL goto :EOF
Thanks but the script didn't work on LTSC 2019. Anyway I'm using a toggle switch right now which drew84 mentioned. But lately I experienced that when I disable Windows Defender with that toggle switch, Defender still quarantined a false positive. I think that Defender Control might be able to do a better job at disabling Defender. It will work with command lines "DefenderControl.exe /D" and "DefenderControl.exe /E". I want to add the toggle script to my Context menu to quickly disable Defender.
Ah strange. I've used it on LTSC 2019 before just fine. Maybe there's a delay before the system recognizes it or you need to reboot or something?
Anyway I need something that will disable Defender quickly, before it quarantines or deletes a file. That's why a toggle script on the context menu.
Found a temp solution. Defender Control has the option to minimize on the system tray so Defender can be disabled and enabled from there.