How to Run a Virus Scan from CMD
You can run various scans to locate virus on CMD
- If you want to run a virus scan from CMD, you will see that it's pretty easy.
- Ensure you type in the correct commands into the Command Prompt app else you’ll trigger the command not recognized error.
- Running full scans provide broader information on the security state of your system.

Windows Defender is Windows’ primary security tool. Sometimes, you might not have access to your GUI and must access Windows Defender directly from the Command Prompt. This article will provide you with the best ways to run a virus scan from CMD.

Secure your devices with award-winning cybersecurity technology.

Keep secure with groundbreaking AI detection and prevention technology.

Browse the web securely for up to 3 devices across Windows, Mac, iOS or Android systems.

Best security tool for intense browsing activity.

Prevent data breaches and malware infections with user-friendly controls.
Can I locate the virus using Command Prompt?
The short answer is yes; you can determine if your system is infected with a virus directly from Command Prompt. Virtually, all actions you carry out in your GUI can be done using the command line e.g Resetting your IP Address, searching for files, changing DNS servers, etc.
Locating viruses and malware using Command Prompt isn’t as intuitive as when done on the GUI. However, with the right steps and guidance, you can achieve exact results on the terminal you usually get on the GUI.
One thing to note about operating your antivirus tool from the command line is that scans generated from the terminal will only provide you with a report of the viruses found in the system; it won’t delete or quarantine them, unlike on the GUI.
After discovering the virus from the Command Prompt app, you must delete it manually.
How can I run a virus scan from CMD?
- Press the Windows key + S, type in command prompt, right-click on the displayed result, and select Run as Administrator.
- In the User Account Control window, select Yes.
- In the CMD window, type in the following command to navigate to the Microsoft Antivirus Directory:
cd C:\ProgramData\Microsoft\Windows Defender\Platform\4.18*
- After navigating to the Windows Defender directory, type in the following to run a quick scan:
MpCmdRun.exe -Scan -ScanType 1
- If you want to run a full scan, type the following command and press Enter:
MpCmdRun.exe -Scan -ScanType 2
- If you need to stop the scan mid-way, press Ctrl + C to quit the scan.
Just like on the GUI app, you’ll see the progress report of the scan. Like on the Windows Defender app, running a quick scan should only take a few minutes, depending on the size of the files stored on your computer.
Expert tip:
SPONSORED
Some PC issues are hard to tackle, especially when it comes to corrupted repositories or missing Windows files. If you are having troubles fixing an error, your system may be partially broken.
We recommend installing Restoro, a tool that will scan your machine and identify what the fault is.
Click here to download and start repairing.
There are cases where you’d like to run a full virus scan. Running a full virus scan ensures that all sectors of your computers are fully scanned. Scans like this take up way much time but are more efficient.
How do I run a custom scan from CMD?
- Click the Start button, type cmd, and select Run as administrator to open an elevated Command Prompt window.
- Type in the following command and press Enter:
MpCmdRun.exe -Scan -ScanType 3 -File PATH
- Ensure you replace PATH with the path to the folder you want to scan. For example, if you want to scan your desktop for viruses, you’ll use the command:
MpCmdRun.exe -Scan -ScanType 3 -File C:\Users\YOURNAME\Desktop
- Ensure you change the YOURNAME to your username.
How do I run a Boot Sector scan
- Windows key + S, type in command prompt, right-click on the displayed result, and select Run as Administrator.
- Type in the following command and press Enter:
MpCmdRun.exe -Scan -ScanType -BootSectorScan
Running this command from the command prompt will scan your PC’s boot sector and remove any suspicious files found in the system. Here is a detailed guide on how to fix a corrupt boot sector.
How do I restore quarantined files using Command Prompt?
- While in the command prompt, type in the following to view the list of quarantined files:
MpCmdRun.exe -Restore -ListAll
- Then type the following command: MyApp.exe along with the name of the file you want to restore, and press Enter.
When Windows Defender detects malicious files, it quarantines them. Oftentimes, the antivirus might mistakenly quarantine legitimate files.
Running a virus scan from the command prompt is less intuitive than the GUI. However, when you’ve been completely locked out of your GUI due to malware, you must run Windows Defender directly from the Command Prompt app.
For this, you will need an elevated Command Prompt window. We have a guide on what to do if you can’t open Command Prompt as administrator.
With the steps outlined above, you can run any virus scan directly from CMD. For any other questions or potential solutions, let us know in the comments section below.
Still having issues? Fix them with this tool:
SPONSORED
If the advices above haven't solved your issue, your PC may experience deeper Windows problems. We recommend downloading this PC Repair tool (rated Great on TrustPilot.com) to easily address them. After installation, simply click the Start Scan button and then press on Repair All.