Share this article

This article is translated in

Improve this guide

How to Use the CMD Virus Scan Command & Remove Malware

To run a full scan, type MpCmdRun.exe -Scan -ScanType 2

3 min. read

Updated onSeptember 5, 2024

updated onSeptember 5, 2024

Share this article

This article is translated in

Improve this guide

Read our disclosure page to find out how can you help Windows Report sustain the editorial teamRead more

Windows Defender is Windows’ primary security tool, and while it has a graphical interface, you can also perform a CMD (Command Prompt) virus scan by using the methods from this guide.

How can I run a virus scan from CMD?

How can I run a virus scan from CMD?

Use the MpCmdRun.exe -Scan command

You can also perform a scan of a custom path with the following command:

MpCmdRun.exe -Scan -ScanType 3 -File C:\Users\YOURNAME\Desktop

Just be sure to enter the desired path after -File in the command.

How do I run a Boot Sector scan

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 onhow to fix a corrupt boot sector.

How do I restore quarantined files using Command Prompt?

Can CMD remove a virus?

CMD can help you remove viruses. By using the command MpCmdRun.exe -Scan -ScanType 2, Microsoft Defender will perform a full scan of your system, quarantining any detected threats.

You can also delete them manually:

How do I scan my PC for malware with Windows Security?

Alternatively, you can use the command line to start the scan more quickly.

Do keep in mind that issues with Defender can occur, and we wrote about what to do ifWindows Defender real-time protection won’t turn on.

Many also reported thatWindows Defender is not workingat all, but that can be easily fixed.

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.

More about the topics:command prompt,Microsoft Windows Defender

Vlad Turiceanu

Windows Editor

Passionate about technology,Windows, and everything that has a power button, he spent most of his time developing new skills and learning more about the tech world.

Coming from a solid background in PC building and software development, with a complete expertise in touch-based devices, he is constantly keeping an eye out for the latest and greatest!

User forum

2 messages

Sort by:LatestOldestMost Votes

Comment*

Name*

Email*

Commenting as.Not you?

Save information for future comments

Comment

Δ

Vlad Turiceanu

Windows Editor

Coming from a solid background in PC building and software development, he’s a Windows 11 Privacy & Security expert.