Use CMD Virus Scan Command To Remove Malware [How to]

Using CMD you can start an antivirus scan in matter of moments

Reading time icon 3 min. read

Readers help support Windows Report. We may get a commission if you buy through our links. Tooltip Icon

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

command prompt virus scan

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

How can I run a virus scan from CMD?

Use the MpCmdRun.exe -Scan command

  1. Press the Windows key + S, type in command prompt, right-click on the displayed result, and select Run as Administrator.
    CMD search results run as administrator
  2. In the User Account Control window, select Yes.
  3. 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*
  4. After navigating to the Windows Defender directory, type in the following to run a quick scan: MpCmdRun.exe -Scan -ScanType 1MpCmdRun.exe -Scan -ScanType 1 command in command prompt
  5. If you want to run a full scan, type the following command and press Enter: MpCmdRun.exe -Scan -ScanType 2
  6. If you need to stop the scan mid-way, press Ctrl + C to quit the scan.

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

  1. Windows key + S, type in command prompt, right-click on the displayed result, and select Run as Administrator.
  2. 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?

  1. While in the command prompt, type in the following to view the list of quarantined files: MpCmdRun.exe -Restore -ListAll
  2. Then type the following command: MyApp.exe along with the name of the file you want to restore, and press Enter.

How do I scan my PC for malware?

  1. Press Windows key + S, type windows security and click on Open.
    Windows Security search results
  2. Select Virus & threat protection.
     windows security virus & threat protection
  3. Now choose Quick scan.

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 if Windows Defender real-time protection won’t turn on.

Many also reported that Windows Defender is not working at 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