Windows 10’s included Microsoft Defender antivirus—also known as Windows Defender—has a command-line interface. Rather than using the graphical Windows Security app, you can run Windows 10’s built-in antivirus from Command Prompt, PowerShell, or Windows Terminal.
Run a Quick Virus Scan
You can run a quick scan to look for viruses, malware, and other threats in some common places, such as the Windows Registry and startup folders. This scan usually only takes a few minutes to finish.
To use this scan, open the “Start” menu, search for “Command Prompt,” right-click the utility, and select “Run as administrator.”
Click “Yes” in the User Account Control prompt.
In the Command Prompt window, type the following to make the Microsoft Defender Antivirus directory your current working directory:
cd C:\ProgramData\Microsoft\Windows Defender\Platform\4.18*
Note: If you make another directory your current working directory or close and reopen the Command Prompt, make sure that you run the above command before using any other Microsoft Defender Antivirus commands.
Then, enter the following command and press “Enter” to start a quick virus scan:
MpCmdRun -Scan -ScanType 1
You’ll see the live scan progress on your screen.
Run a Full Virus Scan
A full scan thoroughly checks all your computer files for viruses, malware, and other security threats. Since this is a comprehensive scan, it tends to take longer than the other scans.
You can run a full scan using the following command in the Command Prompt:
MpCmdRun -Scan -ScanType 2
Note: If you need to stop a scan for some reason, press Ctrl+C on your keyboard.
Perform a Custom Virus Scan
You’ll want to use a custom scan when you have particular files or folders that you want to scan for viruses, malware, and other threats. You can use this to scan files on your external storage as well, such as your USB flash drives.
To use this, type the following command into the Command Prompt window and press “Enter.”
Make sure to replace “PATH” with the path to the folder or file that you want to scan. If there are spaces in your path, add double quotes before and after the path, like this: “C:\Users\Mahesh\Desktop\My Files”
MpCmdRun -Scan -ScanType 3 -File PATH
For instance, if you wanted to scan your desktop for any threats, you’d run the following command, replacing “MYNAME” with your username.
MpCmdRun -Scan -ScanType 3 -File C:\Users\MYNAME\Desktop
Scan Your PC’s Boot Sector Files
Your PC’s boot sector is where all the essential information regarding your computer’s boot-up is stored. This sector contains the code that launches your operating system.
Sometimes, certain viruses and other threats attack this boot sector. When this happens, you experience issues booting up your computer. You could face other issues as well.
RELATED: What to Do When Windows Won't Boot
If you believe your PC is infected with a virus or malware, it’s worth running a boot sector scan to find and remove any suspicious content from this sector.
You can use the following Microsoft Defender Antivirus command to run a boot sector scan:
MpCmdRun -Scan -ScanType -BootSectorScan
Restore Quarantined Files
When Microsoft Defender Antivirus finds a suspicious file, it moves that file to the Quarantine. This is a special location to store suspicious files, and your files can’t launch when they’re here in the Quarantine.
If you believe the antivirus has mistakenly moved a file to the Quarantine, you can use a command to restore that file back to its original location.
To do this, first, run the following command to view a list of all your quarantined files:
MpCmdRun -Restore -ListAll
From the list, note the name of the file that you want to restore. Then type the following command, replace “MyApp.exe” with the name of the file you want to restore, and press “Enter.”
MpCmdRun -Restore -Name MyApp.exe
If you want to restore your file to another folder, use the following command instead. Make sure that you replace “PATH” with the path to your folder before you run the command.
Of course, replace “MyApp.exe” with the name of the file that you want to restore.
MpCmdRun -Restore -Name MyApp.exe -FilePath PATH
Update Microsoft Defender Antivirus
The Microsoft Defender Antivirus updates itself regularly to ensure that it can find newer viruses and threats. However, you can force it to find and download newer updates at any time.
You can do this by running the following command in the Command Prompt window:
It’ll update the virus definitions without any prompts.
View All Available Microsoft Defender Antivirus Options
In addition to the above, there are many other command combinations that you can use to make the most of this antivirus on your Windows 10 PC.
To find all available commands and parameters, run this command in the Command Prompt:
You’re now a pro when it comes to using the Microsoft Defender Antivirus from the Command Prompt.
If you prefer the graphical interface, check out our guide on how to use the Microsoft Defender Antivirus, which explains all the graphical features of this program.