Windows 11 command prompt virus scan guide

Running antivirus scans through Command Prompt in Windows 11 provides advanced control and flexibility, especially when the regular interface isn’t accessible. This guide covers various scanning methods using Windows Defender’s command-line tools.

Opening command prompt with admin rights

Before running any scans, you’ll need administrative access to Command Prompt:

  1. Open the Start menu and search for “Terminal”. Right-click the Terminal result and select “Run as administrator”

  1. When prompted by User Account Control, click “Yes” to proceed

  1. Click the dropdown arrow and choose “Command Prompt” to open a new Command Prompt tab

Full system scan

The most thorough scanning option examines every file, folder, and system area:

  1. Navigate to the Windows Defender directory:
cd C:\ProgramData\Microsoft\Windows Defender\Platform\4.18*

  1. Execute the full scan command:
MpCmdRun -Scan -ScanType 2

Boot sector scan

Scanning the boot sector helps detect malware that targets system startup:

  1. Access the Defender directory:
cd C:\ProgramData\Microsoft\Windows Defender\Platform\4.18*

  1. Run the boot sector scan:
MpCmdRun -Scan -ScanType -BootSectorScan

Custom location scan

Target specific folders or drives for faster scanning:

  1. Enter the Defender directory:
cd C:\ProgramData\Microsoft\Windows Defender\Platform\4.18*

  1. Start the custom scan (replace with your target path):
MpCmdRun -Scan -ScanType 3 -File <directory>

Quick scan

For rapid checking of common malware locations:

  1. Access the Defender folder:
cd C:\ProgramData\Microsoft\Windows Defender\Platform\4.18*

  1. Launch the quick scan:
MpCmdRun -Scan -ScanType 1

Updating virus definitions

Keep protection current by updating virus definitions:

  1. Navigate to Defender’s directory:
cd C:\ProgramData\Microsoft\Windows Defender\Platform\4.18*

  1. Update definitions:
MpCmdRun -SignatureUpdate

Managing quarantined items

Access and restore quarantined files when needed:

  1. Open Defender’s directory:
cd C:\ProgramData\Microsoft\Windows Defender\Platform\4.18*

  1. View quarantined items:
MpCmdRun -Restore -ListAll

  1. Restore all items:
MpCmdRun -Restore -All

  1. Restore specific file:
MpCmdRun -Restore -Name <filename.extension>

  1. Restore file to specific location:
MpCmdRun -Restore -Name <filename.extension> -FilePath <file directory>