用命令行让 Microsoft Defender 扫描单个文件
使用 Defender 自带的命令行工具 MpCmdRun.exe,对某个下载的文件单独查杀,不用做全盘扫描。
运行:"%ProgramFiles%\Windows Defender\MpCmdRun.exe" -Scan -ScanType 3 -File "C:\路径\文件.exe"
01命令
命令
$ "%ProgramFiles%\Windows Defender\MpCmdRun.exe" -Scan -ScanType 3 -File "C:\Users\me\Downloads\file.exe"02作用说明
MpCmdRun.exe 是 Windows Defender 自带的命令行工具,可以按需扫描。-ScanType 3 表示自定义扫描,-File 后面接要检查的文件或文件夹路径。扫描结果会显示在命令行里,如果发现威胁,也会出现在 Windows 安全中心的保护历史记录中。
03风险
!注意: 扫描通过不代表绝对安全——新病毒可能躲过本地特征库,来路不明的文件建议同时上传 VirusTotal 复查。
04撤销
✓无需撤销——该命令不会改变持久状态。
05来源
- Use the command line to manage Microsoft Defender Antivirus依据: 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)依据: Community PowerShell function that invokes MpCmdRun.exe with -Scan -ScanType 3 -File to scan a single path with Windows Defender from the command line.
最后验证: 2026-09-19 · 分类: 安全与隐私