Windows comes with a built-in anti-virus program called Windows Defender. It’s always on, and if you turn it off, Windows will nag you to turn it back on. In the absence of an alternative anti-virus app, we agree that you shouldn’t disable Windows Defender. It might cause problems or slow you down on occasion but that’s better than having an infected computer. Windows Defender usually runs without any problems but on occasion, it might prevent you from downloading certain files, or running or installing certain apps. In such a case, you can temporarily disable Windows Defender. If you often need to disable Windows Defender to run a certain program, it might be easier if you had a simple switch to toggle Windows Defender Real-Time protection.
A Word Of Caution
We don’t recommend disabling Windows Defender each and every time it flags something. You should only disable it, and allow a file to download or run on your system if you are certain it is safe. Disabling Windows Defender isn’t a solution to installing potentially dangerous apps on your system. It’s asking for an infected system.
The trick to the toggle switch is a simple little PowerShell script. Run it once and it will disable Windows Defender, run it a second time and it will enable Windows Defender again. You will need to run the script with Administrative rights because ordinary users cannot disable Windows Defender.
Open Notepad and paste the following in it. Save it with the PS1 file extension.
$preferences = Get-MpPreference Set-MpPreference -DisableRealtimeMonitoring (!$preferences.DisableRealtimeMonitoring)
You can open PowerShell with administrative rights, point it to this script, and run it. Of course, you will want an easier way to do this especially since you cannot auto-run PowerShell scripts. You can create a desktop shortcut that can run the script but you will need to run the shortcut with administrative rights.
Right-click on an empty area on your desktop and select Shortcut. Paste the following in the ‘Browse’ box but replace the ‘Path to script’ with the actual path to the script you created.
RECOMMENDED FOR YOU
%SystemRoot%system32WindowsPowerShellv1.0powershell.exe -ExecutionPolicy Bypass -File "Path to script"
Once you’ve created the shortcut, right-click it and select the ‘Run as administrator’ option. When you run the script and Windows Defender is disabled, you will see a pop-up telling you that it’s been disabled.
It will not automatically be enabled again so we’ll reiterate; do not run a PC without an anti-virus program. Once you’re done running the app you need to, run this script again and Windows Defender will be enabled.
This solution comes from Superuser user yuji.