Scan a single file with Microsoft Defender from the command line
Use the Defender command-line tool MpCmdRun.exe to check one downloaded file for malware without a full system scan.
01Command
$ "%ProgramFiles%\Windows Defender\MpCmdRun.exe" -Scan -ScanType 3 -File "C:\Users\me\Downloads\file.exe"02What it does
MpCmdRun.exe ships with Windows Defender and can scan on demand. -ScanType 3 means a custom scan, and -File restricts it to the single file or folder you name. Results appear in the console, and any detections also show up in Windows Security's protection history.
03Risk
04Undo
✓No undo needed — this command does not change persistent state.
05Sources
- Use the command line to manage Microsoft Defender AntivirusEvidence: Official MpCmdRun.exe reference: the -Scan tool with -ScanType 3 performs a custom scan, and -File <path> limits the scan to a specific file or folder.
- Test-PathUsingWindowsDefender.ps1 (GenXdev.Windows)Evidence: Community PowerShell function that invokes MpCmdRun.exe with -Scan -ScanType 3 -File to scan a single path with Windows Defender from the command line.
Last verified: 2026-09-19 · Category: Security & Privacy
06Related solutions
One command that shows OS version, install date, boot time, memory, network adapters and installed hotfixes.
Built-in Windows command to compute MD5, SHA1 or SHA-256 hashes of any file.
Remove hidden, system and read-only flags from files or whole directory trees.