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:
- Open the Start menu and search for “Terminal”. Right-click the Terminal result and select “Run as administrator”
- When prompted by User Account Control, click “Yes” to proceed
- 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:
- Navigate to the Windows Defender directory:
cd C:\ProgramData\Microsoft\Windows Defender\Platform\4.18*
- Execute the full scan command:
MpCmdRun -Scan -ScanType 2
Boot sector scan
Scanning the boot sector helps detect malware that targets system startup:
- Access the Defender directory:
cd C:\ProgramData\Microsoft\Windows Defender\Platform\4.18*
- Run the boot sector scan:
MpCmdRun -Scan -ScanType -BootSectorScan
Custom location scan
Target specific folders or drives for faster scanning:
- Enter the Defender directory:
cd C:\ProgramData\Microsoft\Windows Defender\Platform\4.18*
- Start the custom scan (replace with your target path):
MpCmdRun -Scan -ScanType 3 -File <directory>
Quick scan
For rapid checking of common malware locations:
- Access the Defender folder:
cd C:\ProgramData\Microsoft\Windows Defender\Platform\4.18*
- Launch the quick scan:
MpCmdRun -Scan -ScanType 1
Updating virus definitions
Keep protection current by updating virus definitions:
- Navigate to Defender’s directory:
cd C:\ProgramData\Microsoft\Windows Defender\Platform\4.18*
- Update definitions:
MpCmdRun -SignatureUpdate
Managing quarantined items
Access and restore quarantined files when needed:
- Open Defender’s directory:
cd C:\ProgramData\Microsoft\Windows Defender\Platform\4.18*
- View quarantined items:
MpCmdRun -Restore -ListAll
- Restore all items:
MpCmdRun -Restore -All
- Restore specific file:
MpCmdRun -Restore -Name <filename.extension>
- Restore file to specific location:
MpCmdRun -Restore -Name <filename.extension> -FilePath <file directory>