Windows 10 released one of the best antivirus that we can find today for the operating system: Windows Defender , also known as Microsoft Defender. This security software is installed by default and allows us to be protected from just installing the operating system against all kinds of computer threats. Like any other program for Windows, this antivirus is designed to be used from a window, with its graphical interface. However, if we are advanced users, why not use it using commands?

The Windows Defender engine is designed to allow system administrators and more advanced users to control security software using commands. The truth is that this does not contribute anything to Microsoft’s antivirus. The same thing that we can do from CMD with the program, we will also be able to do it from its main window. What’s more, from the graphical interface we will have access to more functions.
The main advantage that we will obtain from using Windows antivirus by means of commands is the possibility of creating custom scripts, automating them and even executing an analysis using a keyboard shortcut. And as a drawback, having to memorize the commands, which are not exactly intuitive.

Next we are going to see how we can use Windows Defender by means of commands. These work the same in both CMD and PowerShell and Windows Terminal. Of course, it is essential to run the console with administrator permissions. And first of all, we will execute the following command to place ourselves in the path of the antivirus engine, from where we will execute the commands that we will see below.
cd C:/ProgramData/Microsoft/Windows Defender/Platform/4.18*
Search for viruses in Windows from CMD
Of course, the first thing we will be able to do is analyze our PC in search of malware and programs that may be dangerous. Thus, for example, we will be able to perform a quick scan of the PC in search of malicious software by executing the following command:
MpCmdRun -Scan -ScanType 1
The number at the end of the command indicates the type of scan that we are going to perform. 1, in the example above, indicates a quick scan. If we want a full system scan, then we will change the 1 to a 2.
MpCmdRun -Scan -ScanType 2
We can even scan directories on demand using the number 3, followed by the “file” parameter and the file or folder that we are going to analyze.
MpCmdRun -Scan -ScanType 3 -File "directorio"
Finally, we can also analyze the Windows boot sector to find malware that may have been hidden there with this command:
MpCmdRun -Scan -ScanType -BootSectorScan
Update Windows Defender
But analyzing the PC is not the only thing we can do. How could it be less, this antivirus also has a command thanks to which we will be able to update the database (and the engine, if there is a new version of it) so that we can have the best possible protection. To do this, all we have to do is run:
MpCmdRun -SignatureUpdate
Cancel running tasks
Did we run a command by mistake and Windows Defender started scanning the PC? By not having the interface open, we will not be able to control the antivirus activity from it. However, there is a trick thanks to which we will be able to stop any manual scan that is in progress.
We simply have to execute this command to stop everything that is running:
MpCmdRun -Cancel