How do I turn off Windows Defender from the command line?

I am searching for a command to temporarily turn off Windows Defender.

Any suggestions?


Using PowerShell (as an administrator) in Windows 10, use the following command:

Set-MpPreference -DisableRealtimeMonitoring $true

To re-enable it:

Set-MpPreference -DisableRealtimeMonitoring $false

Source


I am searching for a command to turn off Windows Defender

You can use sc (Service Control) to stop and start Windows Defender:

sc stop WinDefend

And:

sc start WinDefend

Example output:

F:\test>sc stop WinDefend

SERVICE_NAME: WinDefend
        TYPE               : 20  WIN32_SHARE_PROCESS
        STATE              : 4  RUNNING
                                (STOPPABLE, NOT_PAUSABLE, ACCEPTS_SHUTDOWN)
        WIN32_EXIT_CODE    : 0  (0x0)
        SERVICE_EXIT_CODE  : 0  (0x0)
        CHECKPOINT         : 0x0
        WAIT_HINT          : 0x0

F:\test>sc query WinDefend

SERVICE_NAME: WinDefend
        TYPE               : 20  WIN32_SHARE_PROCESS
        STATE              : 1  STOPPED
        WIN32_EXIT_CODE    : 0  (0x0)
        SERVICE_EXIT_CODE  : 0  (0x0)
        CHECKPOINT         : 0x0
        WAIT_HINT          : 0x0

F:\test>sc start WinDefend

SERVICE_NAME: WinDefend
        TYPE               : 20  WIN32_SHARE_PROCESS
        STATE              : 2  START_PENDING
                                (NOT_STOPPABLE, NOT_PAUSABLE, IGNORES_SHUTDOWN)
        WIN32_EXIT_CODE    : 0  (0x0)
        SERVICE_EXIT_CODE  : 0  (0x0)
        CHECKPOINT         : 0x0
        WAIT_HINT          : 0x7d0
        PID                : 6304
        FLAGS              :

F:\test>sc query WinDefend

SERVICE_NAME: WinDefend
        TYPE               : 20  WIN32_SHARE_PROCESS
        STATE              : 4  RUNNING
                                (STOPPABLE, NOT_PAUSABLE, ACCEPTS_SHUTDOWN)
        WIN32_EXIT_CODE    : 0  (0x0)
        SERVICE_EXIT_CODE  : 0  (0x0)
        CHECKPOINT         : 0x0
        WAIT_HINT          : 0x0

Further Reading

  • An A-Z Index of the Windows CMD command line - An excellent reference for all things Windows cmd line related.
  • sc - Service Control - Create, Start, Stop, Query or Delete any Windows SERVICE.

To disable:

sc config WinDefend start= disabled
sc stop WinDefend

To re-enable:

sc config WinDefend start= auto
sc start WinDefend

Don't forget about the space after "start=" or the command will not work.

PS. You can get further description of these commands by typing:

sc /?
sc config /?