How to add Windows Defender to the file context menu in Windows 8 (VBScript)

Introduction

This idea is to add Windows defender related cases to context menu so that people can easily scan files or folders in Windows 8.

Scenarios

Sometimes users want to scan files or folder by using Windows Defender manually. But there are several steps to follow. This script is to solve that.

Script

Step 1: Double click the script.

Step 2: Then it will show UAC message, press YES.

Step 3: After that, it will display a message box as the following.

Note

1. Do not move file scan.ps1 in the script folder.
2. If you want remove the item from context menu, just re-run the script.

Here are some code snippets for your references.

VB Script
Edit|Remove
Sub DeleteSubkeys(HKEY_CLASSES_ROOT, strKeyPath)  
    Dim strSubkey,arrSubkeys,strComputer,objRegistry 
    strComputer = "." 
    Set objRegistry = GetObject("winmgmts:\\" & _ 
    strComputer & "\root\default:StdRegProv") 
    objRegistry.EnumKey HKEY_CLASSES_ROOT, strKeyPath, arrSubkeys  
    If IsArray(arrSubkeys) Then  
        For Each strSubkey In arrSubkeys  
            DeleteSubkeys HKEY_CLASSES_ROOT, strKeyPath & "\" & strSubkey  
        Next  
    End If  
    objRegistry.DeleteKey HKEY_CLASSES_ROOT, strKeyPath  
End Sub

Prerequisite

Windows 8 or later version