Windows – How to do an Automatic Shut Down after a Windows Defender Virus Scan? Would the Task Scheduler be involved

anti-virusscheduled-taskswindowswindows 10windows-defender

I was wondering how I could possibly have my computer automatically shut itself down when Windows Defender is done doing a virus scan. I usually do it at night because I have a Slow CPU and a lot of files and when I am not using it, along with trying to save energy because then it runs all night for no reason… I was thinking the task scheduler would do the trick, but that's for scheduled tasks… Could someone please help?

Best Answer

You're actually on the right track. You would just have to create a Basic Task through the task scheduler. You can then define that you want to do it daily, specify a start time, and then tell it to load a batch file.

Create a batch file (.bat file extension) and add these exact contents to it: start cmd.exe /k "C: && cd \Program Files\Windows Defender && MpCmdRun.exe -SignatureUpdate && MpCmdRun.exe -Scan -2 && shutdown.exe /s /t 00"(this is all on one line) There may be a better way to do this .bat file, but I rarely use batch files so this was the way I know how to implement it.

You'll just want to verify that your Windows Defender is in the \Program Files\Windows Defender location, and I'd assume it's on your C: drive. If not, just change the C: to the correct corresponding drive.

I've never ran Windows Defender through the command line, but I did verify that the signatures update, and the scan does begin. It appears that it will say Scan starting... the entire time it scans. I check through the task manager to ensure that the Windows Defender Service is indeed running.

Try it out and let us know if the scan does complete and the shutdown occurs :)

Related Question