Skip to main content

Remove "Scan with Defender" from context menu

Overview

About this script

This script improves your privacy on Windows.

These changes use Windows system commands to update your settings.

This script removes the Scan with Microsoft Defender option from the right-click context menu.

This script enhances user privacy by limiting engagement with Defender's data collection processes. Defender may collect data during scans and at regular intervals, which some users may find unnecessary or unwanted.

Removing this option only affects the context menu appearance and does not disable Defender or its other functions.

Caution

This may reduce system security by making it less convenient to perform on-demand scans of specific files or folders.

Technical Details

The script functions by altering specific registry keys that correspond to the Defender context menu option. It specifically targets the CLSID {09A47860-11B0-4DA5-AFA5-26D86198A780}, which is associated with this option 1 2. The script alters keys in the HKLM\Software\Classes branch, which automatically reflects in the HKCR (HKEY_CLASSES_ROOT) view 3.

The deletion of this key effectively removes the Scan with Microsoft Defender option from the context menu. This feature is provided by shellext.dll file located in Defender's program files 1.

This script uses Batch (batchfile) scripting language.

Not Advised

This script should only be used by advanced users. This script is not recommended for daily use as it breaks important functionality. Do not run it without having backups and system snapshots.

Implementation Details
  • Language: batch

  • Required Privileges: Administrator rights

  • Compatibility: Windows only

  • Reversibility: Can be undone using provided revert script

Explore Categories

This action belongs to Disable Windows Security interface category. This category offers scripts to disable or modify different aspects of the Windows Security user interface, formerly known as Windows Defender Security Center. Windows Security is a centralized interface managing various Windows security features. It evolved from **Windows... Read more on category page ▶

Apply now

Choose one of three ways to apply:

  1. Automatically via privacy.sexy: The easiest and safest option.
  2. Manually by downloading: Requires downloading a file.
  3. Manually by copying: Advanced flexibility.

Alternative 1. Apply with Privacy.sexy

privacy.sexy is free and open-source application that lets securely apply this action easily.

Open privacy.sexy

You can fully restore this action (revert back to the original behavior) using the application.

privacy.sexy instructions
  1. Open or download the desktop application
  2. Search for the script name: Remove "Scan with Defender" from context menu.
  3. Check the script by clicking on the checkbox.
  4. Click on Run button at the bottom of the page.

Alternative 2. Download

Irreversible Changes

This script is irreversible, meaning there is no straightforward method to restore changes once applied. Exercise caution before running, restoring it may not be possible.

  1. Download the script file by clicking on the button below:

    Download script

  2. Run the script file by clicking on it.

Download revert script

This file restores your system to its original state, before this script is applied.

Download restore script

Alternative 3. Copy

This is for advanced users. Consider automatically applying or downloading the script for simpler way.

  1. Open Command Prompt as administrator.
HELP: Step-by-step guide
  1. Click on Start menu

  2. Type cmd

  3. Right click on Command Prompt select Run as administrator

  4. Click on Yes to run Command Prompt


Animation showing how to open terminal as administrator on Windows 11

  1. Copy the following code:
Code to apply changes
:: Soft-delete the registry key: HKLM\SOFTWARE\Classes\CLSID\{09A47860-11B0-4DA5-AFA5-26D86198A780} 
PowerShell -ExecutionPolicy Unrestricted -Command "function Copy-Acl($Src, $Dst) { $srcKeys = @(Get-ChildItem -LiteralPath $Src -ErrorAction SilentlyContinue); foreach ($key in $srcKeys) { $dstKey = Join-Path $Dst $key.PSChildName; Copy-Acl -Src $key.PSPath -Dst $dstKey; }; $acl = Get-Acl -Path $Src -ErrorAction Stop; $sections = [System.Security.AccessControl.AccessControlSections]::All -band (-bnot [System.Security.AccessControl.AccessControlSections]::Owner); $sddl = $acl.GetSecurityDescriptorSddlForm($sections); $acl.SetSecurityDescriptorSddlForm($sddl, $sections); Set-Acl -Path $Dst -AclObject $acl -ErrorAction Stop; }; function Rename-KeyWithAcl($Old, $New) { try { Copy-Item -LiteralPath $Old -Destination $New -Recurse -Force -ErrorAction Stop; } catch { throw "^""Failed to copy: $_"^""; }; try { Copy-Acl -Src $Old -Dst $New; } catch { Write-Warning "^""Failed to copy ACL: $_"^""; }; try { Remove-Item -LiteralPath $Old -Force -Recurse -ErrorAction Stop | Out-Null; } catch { try { Remove-Item -LiteralPath $New -Force -Recurse -ErrorAction Stop | Out-Null; } catch { Write-Warning "^""Failed to clean up: $_"^""; }; throw "^""Failed to remove: $_"^""; }; }; $rawPath='HKLM\SOFTWARE\Classes\CLSID\{09A47860-11B0-4DA5-AFA5-26D86198A780}'; $suffix='.OLD'; $global:ok = 0; $global:skip = 0; $global:fail = 0; function Rename-KeyTree($Path) { Write-Host "^""Processing key: $Path"^""; if (-Not (Test-Path -LiteralPath $Path)) { Write-Host 'Skipping: Key does not exist.'; $global:skip++; return; }; $values = (Get-Item -LiteralPath $Path -ErrorAction Stop | Select-Object -ExpandProperty Property); foreach ($value in $values) { Write-Host "^""Renaming '$value'"^""; if ($value.EndsWith($suffix)) { Write-Host 'Skipping: Has suffix.'; $global:skip++; continue; }; $backupName = $value + $suffix; Write-Host "^""Renaming to '$backupName'."^""; try { Rename-ItemProperty -LiteralPath $Path -Name $value -NewName $backupName -ErrorAction Stop; Write-Host 'Successfully renamed.'; $global:ok++; } catch { Write-Warning "^""Failed to rename value: $_"^""; $global:fail++; }; }; $subkeys = @(Get-ChildItem -LiteralPath $Path -ErrorAction SilentlyContinue); foreach ($key in $subkeys) { Rename-KeyTree $key.PSPath; }; Write-Host "^""Renaming key '$Path'."^""; if ($Path.EndsWith($suffix)) { Write-Host 'Skipping: Has suffix.'; $global:skip++; } else { $backupPath = $Path + $suffix; while (Test-Path -LiteralPath $backupPath) { $backupPath += $suffix; }; Write-Host "^""Renaming to '$backupPath'."^""; try { Rename-KeyWithAcl -Old $Path -New $backupPath -ErrorAction Stop; Write-Host 'Successfully renamed.'; $global:ok++; } catch { Write-Warning "^""Failed to rename: $_"^""; $global:fail++; }; }; }; Write-Host "^""Soft deleting registry key '$rawPath' recursively."^""; $hive = $rawPath.Split('\')[0]; $path = $hive + ':' + $rawPath.Substring($hive.Length); Rename-KeyTree $path; $totalItems = $global:ok + $global:skip + $global:fail; Write-Host "^""Total items: $totalItems, Renamed: $global:ok, Skipped: $global:skip, Failed: $global:fail"^""; if (($totalItems -eq 0) -or ($totalItems -eq $global:skip)) { Write-Host 'No items were processed. The operation had no effect.'; } elseif ($global:fail -eq $totalItems) { throw "^""Operation failed. All $global:fail items could not be processed."^""; } elseif ($global:ok) { Write-Host "^""Successfully processed $global:ok item(s)."^""; }"
:: Delete the registry value "(Default)" from the key "HKLM\SOFTWARE\Classes\Directory\shellex\ContextMenuHandlers\EPP"
PowerShell -ExecutionPolicy Unrestricted -Command "$keyName = 'HKLM\SOFTWARE\Classes\Directory\shellex\ContextMenuHandlers\EPP'; $valueName = '(Default)'; $hive = $keyName.Split('\')[0]; $path = "^""$($hive):$($keyName.Substring($hive.Length))"^""; Write-Host "^""Removing the registry value '$valueName' from '$path'."^""; if (-Not (Test-Path -LiteralPath $path)) { Write-Host 'Skipping, no action needed, registry key does not exist.'; Exit 0; }; $existingValueNames = (Get-ItemProperty -LiteralPath $path).PSObject.Properties.Name; if (-Not ($existingValueNames -Contains $valueName)) { Write-Host 'Skipping, no action needed, registry value does not exist.'; Exit 0; }; try { if ($valueName -ieq '(default)') { Write-Host 'Removing the default value.'; $(Get-Item -LiteralPath $path).OpenSubKey('', $true).DeleteValue(''); } else { Remove-ItemProperty -LiteralPath $path -Name $valueName -Force -ErrorAction Stop; }; Write-Host 'Successfully removed the registry value.'; } catch { Write-Error "^""Failed to remove the registry value: $($_.Exception.Message)"^""; }"
:: Delete the registry value "(Default)" from the key "HKLM\SOFTWARE\Classes\Drive\shellex\ContextMenuHandlers\EPP"
PowerShell -ExecutionPolicy Unrestricted -Command "$keyName = 'HKLM\SOFTWARE\Classes\Drive\shellex\ContextMenuHandlers\EPP'; $valueName = '(Default)'; $hive = $keyName.Split('\')[0]; $path = "^""$($hive):$($keyName.Substring($hive.Length))"^""; Write-Host "^""Removing the registry value '$valueName' from '$path'."^""; if (-Not (Test-Path -LiteralPath $path)) { Write-Host 'Skipping, no action needed, registry key does not exist.'; Exit 0; }; $existingValueNames = (Get-ItemProperty -LiteralPath $path).PSObject.Properties.Name; if (-Not ($existingValueNames -Contains $valueName)) { Write-Host 'Skipping, no action needed, registry value does not exist.'; Exit 0; }; try { if ($valueName -ieq '(default)') { Write-Host 'Removing the default value.'; $(Get-Item -LiteralPath $path).OpenSubKey('', $true).DeleteValue(''); } else { Remove-ItemProperty -LiteralPath $path -Name $valueName -Force -ErrorAction Stop; }; Write-Host 'Successfully removed the registry value.'; } catch { Write-Error "^""Failed to remove the registry value: $($_.Exception.Message)"^""; }"
  1. Right click on command prompt to paste it.
  2. Press Enter to apply remaining code.

Copy restore code

Copy and run the following code to restore changes:

Revert code
:: Restore registry key: HKLM\SOFTWARE\Classes\CLSID\{09A47860-11B0-4DA5-AFA5-26D86198A780} 
PowerShell -ExecutionPolicy Unrestricted -Command "function Copy-Acl($Src, $Dst) { $srcKeys = @(Get-ChildItem -LiteralPath $Src -ErrorAction SilentlyContinue); foreach ($key in $srcKeys) { $dstKey = Join-Path $Dst $key.PSChildName; Copy-Acl -Src $key.PSPath -Dst $dstKey; }; $acl = Get-Acl -Path $Src -ErrorAction Stop; $sections = [System.Security.AccessControl.AccessControlSections]::All -band (-bnot [System.Security.AccessControl.AccessControlSections]::Owner); $sddl = $acl.GetSecurityDescriptorSddlForm($sections); $acl.SetSecurityDescriptorSddlForm($sddl, $sections); Set-Acl -Path $Dst -AclObject $acl -ErrorAction Stop; }; function Rename-KeyWithAcl($Old, $New) { try { Copy-Item -LiteralPath $Old -Destination $New -Recurse -Force -ErrorAction Stop; } catch { throw "^""Failed to copy: $_"^""; }; try { Copy-Acl -Src $Old -Dst $New; } catch { Write-Warning "^""Failed to copy ACL: $_"^""; }; try { Remove-Item -LiteralPath $Old -Force -Recurse -ErrorAction Stop | Out-Null; } catch { try { Remove-Item -LiteralPath $New -Force -Recurse -ErrorAction Stop | Out-Null; } catch { Write-Warning "^""Failed to clean up: $_"^""; }; throw "^""Failed to remove: $_"^""; }; }; $rawPath='HKLM\SOFTWARE\Classes\CLSID\{09A47860-11B0-4DA5-AFA5-26D86198A780}'; $suffix ='.OLD'; $global:fail = 0; $global:ok = 0; function Get-Real($s) { while ($s.EndsWith($suffix)) { $s = $s.Substring(0, $s.Length - $suffix.Length); }; return $s; }; function Restore-KeyTree($Path) { $dest = Get-Real $Path; $src = $Path; Write-Host "^""Restoring key: '$dest' from '$src'"^""; if (-Not $src.EndsWith($suffix)) { $src += $suffix; if (-Not (Test-Path -LiteralPath $src)) { Write-Host 'Skipping: No data.'; Restore-Children $dest; return; }; }; if (Test-Path -LiteralPath $dest) { Write-Host 'Skipping to avoid data loss. Key already exists.'; Write-Warning "^""Manual intervention may be required to fully restore from '$src'."^""; } else { try { Rename-KeyWithAcl -Old $src -New $dest -ErrorAction Stop; Write-Host 'Successfully restored.'; $global:ok++; } catch { Write-Warning "^""Failed: $_"^""; $global:fail++; }; }; Restore-Children $dest; }; function Restore-Children($Path) { Write-Host "^""Restoring values in '$Path'"^""; if (-Not (Test-Path -LiteralPath $Path)) { Write-Host 'Skipping: Key does not exist. No action needed.'; return; }; $values = ( Get-Item -LiteralPath $Path -ErrorAction Stop | Select-Object -ExpandProperty Property ); foreach ($value in $values) { Write-Host "^""Restoring value '$value'"^""; if (-Not $value.EndsWith($suffix)) { Write-Host 'Skipping: No action needed.'; continue; }; $real = Get-Real $value; Write-Host "^""Renaming to '$real'."^""; try { Rename-ItemProperty -LiteralPath $Path -Name $value -NewName $real -ErrorAction Stop; Write-Host 'Successfully restored.'; $global:ok++; } catch { Write-Warning "^""Failed: $_"^""; $global:fail++; }; }; $keys = @(Get-ChildItem -LiteralPath $Path -ErrorAction SilentlyContinue); foreach ($key in $keys) { Restore-KeyTree $key.PSPath; }; }; Write-Host "^""Restoring registry key '$rawPath' recursively."^""; $hive = $rawPath.Split('\')[0]; $path = $hive + ':' + $rawPath.Substring($hive.Length); Restore-KeyTree $path; if ($global:fail) { Write-Error 'Failed to restore'; Exit 1; }"
:: Restore the registry value "(Default)" in key "HKLM\SOFTWARE\Classes\Directory\shellex\ContextMenuHandlers\EPP" to its original value
PowerShell -ExecutionPolicy Unrestricted -Command "$data = '{09A47860-11B0-4DA5-AFA5-26D86198A780}'; $rawType = 'REG_SZ'; $rawPath = 'HKLM\SOFTWARE\Classes\Directory\shellex\ContextMenuHandlers\EPP'; $value = '(Default)'; $hive = $rawPath.Split('\')[0]; $path = "^""$($hive):$($rawPath.Substring($hive.Length))"^""; Write-Host "^""Restoring value '$value' at '$path' with type '$rawType' and value '$data'."^""; if (-Not $rawType) { throw "^""Internal privacy$([char]0x002E)sexy error: Data type is not provided for data '$data'."^""; }; if (-Not (Test-Path -LiteralPath $path)) { try { New-Item -Path $path -Force -ErrorAction Stop | Out-Null; Write-Host 'Successfully created registry key.'; } catch { throw "^""Failed to create registry key: $($_.Exception.Message)"^""; }; }; $currentData = Get-ItemProperty -LiteralPath $path -Name $value -ErrorAction SilentlyContinue | Select-Object -ExpandProperty $value; if ($currentData -eq $data) { Write-Host 'Skipping, no changes required, the registry data is already as expected.'; Exit 0; }; try { $type = switch ($rawType) { 'REG_SZ' { 'String' }; 'REG_DWORD' { 'DWord' }; 'REG_QWORD' { 'QWord' }; 'REG_EXPAND_SZ' { 'ExpandString' }; default { throw "^""Internal privacy$([char]0x002E)sexy error: Failed to find data type for: '$rawType'."^""; }; }; Set-ItemProperty -LiteralPath $path -Name $value -Value $data -Type $type -Force -ErrorAction Stop; Write-Host 'Successfully restored the registry value.'; } catch { throw "^""Failed to restore the value: $($_.Exception.Message)"^""; }"
:: Restore the registry value "(Default)" in key "HKLM\SOFTWARE\Classes\Drive\shellex\ContextMenuHandlers\EPP" to its original value
PowerShell -ExecutionPolicy Unrestricted -Command "$data = '{09A47860-11B0-4DA5-AFA5-26D86198A780}'; $rawType = 'REG_SZ'; $rawPath = 'HKLM\SOFTWARE\Classes\Drive\shellex\ContextMenuHandlers\EPP'; $value = '(Default)'; $hive = $rawPath.Split('\')[0]; $path = "^""$($hive):$($rawPath.Substring($hive.Length))"^""; Write-Host "^""Restoring value '$value' at '$path' with type '$rawType' and value '$data'."^""; if (-Not $rawType) { throw "^""Internal privacy$([char]0x002E)sexy error: Data type is not provided for data '$data'."^""; }; if (-Not (Test-Path -LiteralPath $path)) { try { New-Item -Path $path -Force -ErrorAction Stop | Out-Null; Write-Host 'Successfully created registry key.'; } catch { throw "^""Failed to create registry key: $($_.Exception.Message)"^""; }; }; $currentData = Get-ItemProperty -LiteralPath $path -Name $value -ErrorAction SilentlyContinue | Select-Object -ExpandProperty $value; if ($currentData -eq $data) { Write-Host 'Skipping, no changes required, the registry data is already as expected.'; Exit 0; }; try { $type = switch ($rawType) { 'REG_SZ' { 'String' }; 'REG_DWORD' { 'DWord' }; 'REG_QWORD' { 'QWord' }; 'REG_EXPAND_SZ' { 'ExpandString' }; default { throw "^""Internal privacy$([char]0x002E)sexy error: Failed to find data type for: '$rawType'."^""; }; }; Set-ItemProperty -LiteralPath $path -Name $value -Value $data -Type $type -Force -ErrorAction Stop; Write-Host 'Successfully restored the registry value.'; } catch { throw "^""Failed to restore the value: $($_.Exception.Message)"^""; }"

Support

This website relies on your support.

Support now

Your donation helps keep the project alive and improves its content ❤️.

Share this page: