You can use Windows Defender with command lines to run the antivirus manually or to automate certain tasks, and in this guide, we show you how.

Windows Defender is the free antivirus software that Microsoft has created to offer the first line of defense against malware on PCs. The security software comes built-in on Windows 10 and Windows 8.1, and it identifies and removes viruses, spyware, rootkits and bootkits, and a number of other malicious code.

The software most of the time runs quietly in the background, and it includes a very easy to use interface. However, what you probably didn't know is that you can also use Windows Defender with command lines, which can come in handy in a number of scenarios, including when you're trying to automate certain tasks using Task Scheduler.

Interesting enough, there are at least two ways to use Windows Defender with Command Prompt: You can either use MSASCui.exe, which allows you to control the antivirus Graphical User Interface (GUI) using command lines. Or you can use MpCmdRun.exe, which is the official command line utility with more options and commands run silently in the background by default.

In this Windows 10 guide, we'll walk you through the command lines to use Windows Defender on your computer.

How to use Windows Defender with Command Prompt

The following commands using MSASCui.exe let you update and run the Windows Defender different scan modes, but every execution will launch the application to perform the task and you get limited options compared to the MpCmdRun.exe utility.

Use the Windows key + I keyboard shortcut to open the Power User menu and select Command Prompt (Admin), then:

To trigger an update check followed by a quick virus scan, type the following command and press Enter:

"%ProgramFiles%\Windows Defender\MSASCui.exe" -UpdateAndQuickScan

To download and install updates for Windows Defender, type the following command and press Enter:

"%ProgramFiles%\Windows Defender\MSASCui.exe" -Update

To perform a quick Windows Defender scan, type the following command and press Enter:

"%ProgramFiles%\Windows Defender\MSASCui.exe" -QuickScan

To perform a full scan, type the following command and press Enter:

"%ProgramFiles%\Windows Defender\MSASCui.exe" -FullScan

Quick Tip: You can also append the -hide switch at the end of each command to prevent the Windows Defender from opening up. Here's an example: "C:\Program Files\Windows Defender\MSASCui.exe" -UpdateAndQuickScan -hide.

How to use Windows Defender silently with Command Prompt

Windows Defender also includes a command-line utility, MpCmdRun.exe, which you can use to automate or run tasks silently without having to launch the desktop client.

Use the Windows key + I keyboard shortcut to open the Power User menu and select Command Prompt (Admin), then:

To trigger a signature update, type the following command and press Enter:

"%ProgramFiles%\Windows Defender\MpCmdRun.exe" -SignatureUpdate

To perform a quick scan, type the following command and press Enter:

"%ProgramFiles%\Windows Defender\MpCmdRun.exe" -Scan -ScanType 1

To perform a full Windows Defender scan, type the following command and press Enter:

"%ProgramFiles%\Windows Defender\MpCmdRun.exe" -Scan -ScanType 2

To do a custom scan for a file or folder instead of scanning your entire system, type the following command and press Enter:

"%ProgramFiles%\Windows Defender\MpCmdRun.exe" -Scan -ScanType 3 -File PATH-TO-FILE-OR-FOLDER

Here's an example that scans all the files and folders within the Public folder:

"%ProgramFiles%\Windows Defender\MpCmdRun.exe" -Scan -ScanType 3 -File C:\Users\Public

You can also scan and remove any malicious code that may have infected the boot sector with the following command:

"%ProgramFiles%\Windows Defender\MpCmdRun.exe" -Scan -ScanType -BootSectorScan

Keep in mind that we're only listing the most useful commands, you can also run the following command to view a handful of other switches to use alongside the MpCmdRun.exe utility.

"%ProgramFiles%\Windows Defender\MpCmdRun.exe"

Finally, it's important to note that while we're focusing this guide on Windows 10, these instructions should also be compatible with previous versions of the operating system, including Windows 7 and Windows 8.1.

More Windows 10 resources

For more help articles, coverage, and answers on Windows 10, you can visit the following resources: