Technology Blog

How To Run Windows Defender as Command-line to Automate Tasks in Windows 10

0

Windows Defender is the default anti-malware built right in the Windows. Usually, it runs quietly as a service with a GUI that you can use to run some tasks manually. Do you also know that you can run Windows Defender as a command-line so you can automate tasks with Task Scheduler?

windows-defender-2016-10-05-21_49_48

MSASCui.exe

MSASCui.exe is the Windows Defender GUI executable that also comes with the switches you can run as the command-line.

Run the updates followed by a quick scan

"%ProgramFiles%Windows DefenderMSASCui.exe" -UpdateAndQuickScan

Run a quick scan

"%ProgramFiles%Windows DefenderMSASCui.exe" -QuickScan

Run a full scan

"%ProgramFiles%Windows DefenderMSASCui.exe" -FullScan

Run the updates

"%ProgramFiles%Windows DefenderMSASCui.exe" -Update

Run the tasks in hidden mode

To run any of the above tasks without the GUI window showing up, add the “-hide” at the end.

MpCmdRun.exe

MpCmdRun.exe is the Windows Defender Console that also comes with quite a few switches that you can use.

Run the updates followed by a quick scan

"%ProgramFiles%Windows DefenderMpCmdRun.exe" -SignatureUpdateAndQuickScan

Run a quick scan

"%ProgramFiles%Windows DefenderMpCmdRun.exe" -Scan -ScanType 1

Run a full scan

"%ProgramFiles%Windows DefenderMpCmdRun.exe" -Scan -ScanType 2

Run a scan on file or directory

"%ProgramFiles%Windows DefenderMpCmdRun.exe" -Scan -ScanType 3 -File <Path>

Run a scan on the boot sector

"%ProgramFiles%Windows DefenderMpCmdRun.exe" -Scan -ScanType 3 -BootSectorScan

Run the updates

"%ProgramFiles%Windows DefenderMpCmdRun.exe" -SignatureUpdate

To see the complete list

"%ProgramFiles%Windows DefenderMpCmdRun.exe"

command-prompt-mpcmdrun

With these switches available in hand, you can easily create a task in Task Scheduler with the proper switch to automate the tasks like running updates, performing a full scan or custom scan on a certain type of files or folders, etc.

Source