How to Enable or Disable Tamper Protection using Start Windows Defender: A Batch Script

Abstract: This batch script enables or disables Windows Defender Tamper Protection by modifying the registry, bypassing UI restrictions for automated configuration.

Created: 2026-10-24 by
You can toggle Windows Defender Tamper Protection by modifying the registry key HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows Defender\Features\TamperProtection using a batch script. This method bypasses the UI restrictions that normally prevent users from disabling this critical security feature, allowing for automated configuration or emergency troubleshooting when the standard interface is locked down.

Understanding Tamper Protection and Registry Keys

Tamper Protection is a security feature in Microsoft Defender Antivirus designed to prevent unauthorized changes to your security settings. When enabled, it blocks attempts to turn off real-time protection, disable scanning, or modify definitions without proper administrative privileges. While this protects against malware, it also prevents legitimate administrators from making necessary adjustments via the graphical user interface (GUI) during specific troubleshooting scenarios.

The state of Tamper Protection is controlled by a DWORD value named TamperProtection located in the registry path HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows Defender\Features. The value data determines the status:

  • 5: Tamper Protection is Enabled.
  • 0: Tamper Protection is Disabled.

Modifying this key directly via a batch script requires elevated permissions because it resides under the HKEY_LOCAL_MACHINE hive, which affects the entire system rather than just the current user profile.

Creating the Batch Script

To create a script that allows you to choose between enabling or disabling Tamper Protection, we will use the built-in choice command. This command provides a simple menu interface in the command prompt, allowing the user to select an option with a single keystroke. For more complex input handling, such as returning specific keys, you might refer to guides on Using the Windows Batch Script: Return ENTER Key with 'choice' command, though the basic implementation below suffices for binary choices.

@echo off
title Toggle Windows Defender Tamper Protection
setlocal enabledelayedexpansion

:: Check for administrative privileges
net session >nul 2>&1
if %errorLevel% neq 0 (
    echo ERROR: This script must be run as Administrator.
    echo Right-click the script and select "Run as administrator".
    pause
    exit /b 1
)

:MENU
cls
echo ========================================
echo   Tamper Protection Manager
echo ========================================
echo.
echo Current Status: Checking...
reg query "HKLM\SOFTWARE\Microsoft\Windows Defender\Features" /v TamperProtection /reg:64 2>nul | findstr "0x5" >nul
if !errorlevel! equ 0 (
    echo Status: ENABLED
    set STATUS=Enabled
) else (
    echo Status: DISABLED
    set STATUS=Disabled
)
echo.
echo Please select an action:
echo [1] Enable Tamper Protection
echo [2] Disable Tamper Protection
echo [3] Exit
echo.
set /p choice="Enter your choice (1-3): "

if "%choice%"=="1" goto ENABLE
if "%choice%"=="2" goto DISABLE
if "%choice%"=="3" goto END

echo Invalid choice. Please try again.
pause
goto MENU

:ENABLE
echo Enabling Tamper Protection...
reg add "HKLM\SOFTWARE\Microsoft\Windows Defender\Features" /v TamperProtection /t REG_DWORD /d 5 /f /reg:64
if !errorlevel! equ 0 (
    echo Success: Tamper Protection has been enabled.
) else (
    echo Error: Failed to update registry.
)
pause
goto MENU

:DISABLE
echo Disabling Tamper Protection...
reg add "HKLM\SOFTWARE\Microsoft\Windows Defender\Features" /v TamperProtection /t REG_DWORD /d 0 /f /reg:64
if !errorlevel! equ 0 (
    echo Success: Tamper Protection has been disabled.
) else (
    echo Error: Failed to update registry.
)
pause
goto MENU

:END
echo Exiting Tamper Protection Manager.
exit /b

How the Script Works

The script begins by checking if it is running with administrative privileges using the net session command. If the user does not have admin rights, the script terminates immediately with an error message, preventing permission denied errors later in the process. This is a crucial step because modifying HKEY_LOCAL_MACHINE keys requires elevation.

The main loop presents a clear menu to the user, displaying the current status of Tamper Protection before offering options. It uses reg query to read the existing value of TamperProtection. If the value is 0x5, the script identifies the status as Enabled; otherwise, it assumes Disabled. This feedback ensures the user knows the current state before making changes.

When the user selects option 1 or 2, the script executes the reg add command. The flags used are:

  • /v TamperProtection: Specifies the name of the registry value.
  • /t REG_DWORD: Specifies the data type as a 32-bit integer.
  • /d 5 or /d 0: Sets the data to Enable or Disable respectively.
  • /f: Forces overwriting of the existing value without prompting.
  • /reg:64: Ensures the script targets the 64-bit registry view, which is important on 64-bit systems to avoid redirection issues.

Alternative Automation Methods

If you need to perform other automated tasks alongside this change, such as opening folders or managing scripts, you might find related techniques useful. For instance, understanding how to Effortlessly Open Multiple Folders and Tabs with a Batch Script can help you organize your security tools or logs after toggling protection. However, for simple registry toggles, the provided script is sufficient and self-contained.

Risks and Considerations

Disabling Tamper Protection leaves your system vulnerable to malware that attempts to disable security features. Malware often tries to turn off real-time protection to install itself silently. Therefore, it is recommended to only disable Tamper Protection temporarily for specific troubleshooting purposes and re-enable it immediately afterward.

Additionally, some third-party antivirus software may conflict with Windows Defender. If you are installing another antivirus solution, you may need to disable Tamper Protection first to allow the new software to take full control. In such cases, ensure that the new antivirus is fully configured and active before closing the window.

Frequently Asked Questions

Why does my script fail with "Access Denied"?

This error occurs because the script is not running with administrative privileges. You must right-click the batch file and select "Run as administrator" to gain the necessary permissions to modify HKEY_LOCAL_MACHINE registry keys.

Can I disable Tamper Protection via Group Policy instead?

Yes, but Group Policy Objects (GPO) typically manage broader security configurations. While GPO can enforce certain Defender settings, Tamper Protection is primarily managed via the registry or local policy. Using a batch script offers a quicker, manual override for individual machines.

Does disabling Tamper Protection turn off Real-Time Protection?

No. Disabling Tamper Protection only removes the lock that prevents changes to security settings. You still need to manually disable Real-Time Protection through the Settings app or the registry key DisableRealtimeMonitoring if you wish to stop active scanning.

Will this script work on Windows 11?

Yes, the registry structure for Tamper Protection remains consistent across Windows 10 and Windows 11. The script uses standard commands compatible with both operating systems, provided they are running on 64-bit versions where the /reg:64 flag is relevant.

What should I do if the registry key doesn't exist?

If the TamperProtection key is missing, it usually means Tamper Protection is already disabled or the version of Windows Defender is outdated. You can create the key manually using the reg add command with the /f flag, which creates the key if it does not exist.

Latest News

How to Display Output of xterm Command in Terminal Screen using Cron

Resolve the inability to display xterm output in a terminal screen from cron by redirecting logs or using wall instead of insecure X11 workarounds.

Read More
Expose Local Server on VPS Preserving Real Client IPs (OS Level)

Resolve VPS logging showing only gateway IPs by configuring reverse proxies to forward real client addresses via X-Forwarded-For headers.

Read More
How to Clear Recent Files History in Linux without Deleting Actual Files?

Clear recent files history in Linux by deleting ~/.local/share/recently-used.xbel without removing the actual files.

Read More
Best HDD Copy Strategy: Manually Syncing and Rewriting Scratch

Resolve data drift between two 4TB hard drives by using rsync with the --delete flag to manually sync and rewrite scratch data for an exact mirror.

Read More
Understanding Bash Prompt Abbreviations: An Overview

Resolve repetitive typing errors by creating and persisting Bash aliases in the .bashrc file for improved command-line efficiency.

Read More
Free Tools and Methods to Log Real-Time Performance Details in Task Manager

Log real-time CPU and memory metrics to CSV files using Windows Performance Monitor Data Collector Sets to troubleshoot system slowness.

Read More
Contact Qatar Airways Customer Service: Phone Number, Help Center, and More

Resolve urgent Qatar Airways reservation issues like flight changes and baggage claims using the US phone number +1801-855-5905 or online self-service tools.

Read More
Windows 11: Alt Codes Displaying Wrong Characters - Solutions

Resolve Windows 11 Alt codes showing wrong characters by verifying the US keyboard layout and enabling Num Lock.

Read More
Run Programs with Elevated Privileges: A Comprehensive Guide

Eliminates the need to type sudo for frequent administrative tasks by configuring .bashrc aliases or functions.

Read More
Dynamically Changing Dates in Excel Formulas Using Cells

Eliminate manual date updates in Excel by using cell references to create dynamic formulas that automatically adjust calculations when input dates change.

Read More
Granting Edit Access to a Specific Excel Sheet in an Office 365 User Email ID-Based Login

Excel Online lacks native sheet-level permissions, so users must split workbooks or use worksheet protection to isolate edit access for specific tabs.

Read More
Creating Network Load on Local Wi-Fi from One PC

Generate sustained Wi-Fi bandwidth load from a single PC using a VM SFTP server to test router stability and throughput.

Read More
Changing the Default Editor for Batch Files in Windows 11's File Explorer

Resolve the issue of batch files opening in Notepad by changing the default editor to a preferred application like VS Code.

Read More
Gain WiFi Connection Minutes Before Losing it by Changing MAC Address

Bypass MAC address filtering to restore WiFi connectivity temporarily when a device is blocked by network administrators.

Read More
Photos Folders Turned Black: Troubleshooting Picture Applications on Windows

Resolve black screens in Windows Photos by resetting the app, updating graphics drivers, and repairing system files.

Read More
Troubleshooting High CPU Temperature Values: A Step-by-Step Guide

Resolve high CPU temperatures and thermal throttling by monitoring with Speedfan, cleaning dust from cooling components, and replacing degraded thermal paste.

Read More
Make cURL establish TLS connection with CA unknown

Resolve cURL TLS connection failures with unknown or self-signed certificates by using the --insecure flag to bypass CA validation.

Read More
Troubleshooting Incorrect Network Metrics Values in Grafana, Prometheus, InfluxDB, and Telegraf

Fix incorrect network metrics in Grafana, Prometheus, InfluxDB, and Telegraf by verifying interface selection, resolving unit mismatches, and handling counter resets.

Read More
Start Another Terminal Window (cmd.exe) Windows Repair/Troubleshoot

Provides step-by-step instructions to access the Windows Command Prompt via bootable media for advanced system repair and troubleshooting.

Read More
Thinkpad P1 Gen 6: Sudden Thunderbolt 3 Dock USB-C Charging Stopped Working

Resolve sudden Thunderbolt 3 dock USB-C charging and internet failure on ThinkPad P1 Gen 6 by updating firmware, resetting the dock, and adjusting power settings.

Read More
ASUS Windows 11 Laptop: Internet Connection Issue with Hotspot

Resolve ASUS Windows 11 laptop spinning wheel issue when connecting to mobile hotspot by resetting network stack, disabling IPv6, and adjusting power settings.

Read More
Developing iOS Project with Firebase: Logging in and Sending Push Notifications

Integrates Firebase to enable secure user authentication and push notifications in iOS applications.

Read More
Troubleshooting Bash Script with Suspected Issues of Spaces, Dashes, Filenames and Quoting

Resolve Bash script failures caused by word splitting, globbing, and special characters in filenames by applying proper quoting techniques.

Read More
Populating OneDrive Folder for Local Backup without Affecting Remote Files

Prevent OneDrive from deleting remote files during Windows reinstallation by unlinking the account or using symbolic links to isolate local data.

Read More
Force First Frame as Keyframe Without Re-encoding: A Quick Solution

Resolve inaccurate seeking and playback glitches by re-encoding video to ensure the first frame is a valid keyframe.

Read More
Find Information in Database Using WSL (Ubuntu) on Windows-10

Resolve database connection issues from WSL Ubuntu on Windows 10 by configuring client tools and network access to query remote or local servers.

Read More
Configuring a New Router with Different Networks: One Family, One Guest

Resolve IP conflicts and isolate guest traffic by configuring a second router with a distinct subnet via its WAN port.

Read More
Quickly Open Multiple Stock Websites with a Single Command

Solve the problem of manually opening multiple stock research websites by creating a single command to launch them simultaneously on Windows, macOS, or Linux.

Read More
Improved Adobe Acrobat Search Experience: Access Advanced Search with Ease

Access advanced search filters like case sensitivity and regex in Adobe Acrobat by clicking More Options in the Find bar.

Read More
Port Forwarding VM via OpenVPN: A Comprehensive Guide

Configure OpenVPN server and iptables to forward specific ports from VPN clients to a virtual machine's internal IP address.

Read More
Understanding Partitions in the 1980s: A Look Back at MS-DOS and Master Boot Record

Explains how the Master Boot Record and partition table enabled MS-DOS to manage multiple disk volumes on a single physical drive.

Read More
Windows 10 Enterprise: Keyboard Not Detected in Managed Organization with Admin Privileges

Resolve Windows 10 Enterprise keyboard detection failures caused by Group Policy restrictions, driver corruption, or USB enumeration errors.

Read More
Can't Find x86_64 Versions of Applications on MacOS arm64 (M1)

Resolve missing x86_64 app issues on M1 Macs by installing Rosetta 2 and reinstalling apps as universal binaries.

Read More
How to Hide Installation Source for an Android App

Manage Android app installation source visibility by using USB transfers or file managers to reduce browser traces and isolate data via work profiles.

Read More
Connecting Momentus 4200.2 ST9808210A Hard Drive via USB Cable

Resolve inability to access Seagate Momentus 4200.2 ST9808210A hard drive by connecting it via USB using a compatible SATA-to-USB adapter and configuring the disk in Windows.

Read More