Disable Defender Antivirus data storage location
Overview
This script improves your privacy on Windows.
These changes use Windows system commands to update your settings.
This script removes a configuration value that controls where Defender stores its data.
This is a configuration related to Defender Antivirus 1.
Windows configures this setting when installing Defender Antivirus service 2.
It specifies where data, including virus definition databases and other detection files, is installed 3.
It is used by various Defender components like MpClient.dll
4, MpSvc.dll
5, MsMpEng.exe
6 and MpCmdRun.exe
7.
Deleting this value enhances privacy by preventing these components from accessing their data directories. This reduces their data collection capabilities.
However, this change has significant security risks:
- It may weaken Defender Antivirus's ability to detect and remove malware
- Some security features of Defender Antivirus may not work properly
- This may make your system more vulnerable to security threats
This action may leave your system less protected against viruses and malware.
Technical Details
The script deletes the HKLM\SOFTWARE\Microsoft\Windows Defender!ProductAppDataPath
registry value 1 2.
In earlier Windows versions, this value was found at HKLM\SOFTWARE\Microsoft\Microsoft Antimalware!ProductAppDataPath
3.
When this value is removed, Windows logs Event ID 5007 1. The event message states 1:
Microsoft Defender Antivirus Configuration has changed.
If this is an unexpected event you should review the settings as this may be the result of malware.
According to tests, Windows 10 Pro (≥ 22H2) and Windows 11 Pro (≥ 21H2) have protective measures that may prevent this change from taking effect or may quickly reverse it.
This script uses Batch (batchfile) scripting language.
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
- Disable Defender Antivirus service
- Disable Defender services and drivers
- Disable Defender Antivirus
- Disable Defender
- Privacy over security
This action belongs to Disable Defender Antivirus service category. This category disables the Defender Antivirus service and its related components. This service is also referred to as Microsoft Defender Antivirus Service and Windows Defender Service. It is a core component of Microsoft Defender Antivirus, essential for its operation. Using these... Read more on category page ▶
This action belongs to Disable Defender services and drivers category. This category configures Windows using 15 scripts. These scripts are organized in 1 categories. The category includes 4 subscripts and 1 subcategories that include more scripts and categories. Read more on category page ▶
This action belongs to Disable Defender Antivirus category. This category provides scripts to disable Defender Antivirus. Defender Antivirus, integrated into Windows, provides protection against viruses, ransomware, and other types of malware. Disabling Defender Antivirus may improve system performance and privacy by stopping related data collection... Read more on category page ▶
This action belongs to Disable Defender category. This category offers scripts to disable Windows security components related to Defender. Defender is also referred to as Microsoft Defender or Windows Defender. Although designed to protect you, its features may compromise your privacy and decrease computer performance. Privacy concerns... Read more on category page ▶
This action belongs to Privacy over security category. This category configures Windows using 254 scripts. These scripts are organized in 57 categories. The category includes 3 subcategories that include more scripts and categories. Read more on category page ▶
Apply now
Choose one of three ways to apply:
- Automatically via privacy.sexy: The easiest and safest option.
- Manually by downloading: Requires downloading a file.
- 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.
You can fully restore this action (revert back to the original behavior) using the application.
privacy.sexy instructions
- Open or download the desktop application
- Search for the script name:
Disable Defender Antivirus data storage location
. - Check the script by clicking on the checkbox.
- Click on Run button at the bottom of the page.
Alternative 2. Download
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.
-
Download the script file by clicking on the button below:
-
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.
Alternative 3. Copy
This is for advanced users. Consider automatically applying or downloading the script for simpler way.
- Open Command Prompt as administrator.
HELP: Step-by-step guide
-
Click on Start menu
- Windows 11
- Windows 10
-
Type cmd
- Windows 11
- Windows 10
-
Right click on Command Prompt select Run as administrator
- Windows 11
- Windows 10
-
Click on Yes to run Command Prompt
- Windows 11
- Windows 10
- Windows 11
- Windows 10
- Copy the following code:
:: Delete the registry value "ProductAppDataPath" from the key "HKLM\SOFTWARE\Microsoft\Windows Defender"
PowerShell -ExecutionPolicy Unrestricted -Command "function Invoke-AsTrustedInstaller($Script) { $principalSid = [System.Security.Principal.SecurityIdentifier]::new('S-1-5-80-956008885-3418522649-1831038044-1853292631-2271478464'); $principalName = $principalSid.Translate([System.Security.Principal.NTAccount]); $streamFile = New-TemporaryFile; $scriptFile = New-TemporaryFile; try { $scriptFile = Rename-Item -LiteralPath $scriptFile -NewName ($scriptFile.BaseName + '.ps1') -Force -PassThru; $Script | Out-File $scriptFile -Encoding UTF8; $taskName = "^""privacy$([char]0x002E)sexy invoke"^""; schtasks.exe /delete /tn $taskName /f 2>&1 | Out-Null; $executionCommand = "^""powershell.exe -ExecutionPolicy Bypass -File '$scriptFile' *>&1 | Out-File -FilePath '$streamFile' -Encoding UTF8"^""; $action = New-ScheduledTaskAction -Execute 'powershell.exe' -Argument "^""-ExecutionPolicy Bypass -Command `"^""$executionCommand`"^"""^""; $settings = New-ScheduledTaskSettingsSet -AllowStartIfOnBatteries -DontStopIfGoingOnBatteries; Register-ScheduledTask -TaskName $taskName -Action $action -Settings $settings -Force -ErrorAction Stop | Out-Null; try { ($scheduleService = New-Object -ComObject Schedule.Service).Connect(); $scheduleService.GetFolder('\').GetTask($taskName).RunEx($null, 0, 0, $principalName) | Out-Null; $timeout = (Get-Date).AddMinutes(5); Write-Host "^""Running as $principalName"^""; while ((Get-ScheduledTaskInfo $taskName).LastTaskResult -eq 267009) { Start-Sleep -Milliseconds 200; if ((Get-Date) -gt $timeout) { Write-Warning 'Skipping: Timeout'; break; }; }; if (($result = (Get-ScheduledTaskInfo $taskName).LastTaskResult) -ne 0) { Write-Error "^""Failed, due to exit code: $result."^""; } } finally { schtasks.exe /delete /tn $taskName /f | Out-Null; }; Get-Content $streamFile } finally { Remove-Item $streamFile, $scriptFile; }; }; $cmd = '$keyName = ''HKLM\SOFTWARE\Microsoft\Windows Defender'''+"^""`r`n"^""+'$valueName = ''ProductAppDataPath'''+"^""`r`n"^""+'$hive = $keyName.Split(''\'')[0]'+"^""`r`n"^""+'$path = "^""$($hive):$($keyName.Substring($hive.Length))"^""'+"^""`r`n"^""+'Write-Host "^""Removing the registry value ''$valueName'' from ''$path''."^""'+"^""`r`n"^""+'if (-Not (Test-Path -LiteralPath $path)) {'+"^""`r`n"^""+' Write-Host ''Skipping, no action needed, registry key does not exist.'''+"^""`r`n"^""+' Exit 0'+"^""`r`n"^""+'}'+"^""`r`n"^""+'$existingValueNames = (Get-ItemProperty -LiteralPath $path).PSObject.Properties.Name'+"^""`r`n"^""+'if (-Not ($existingValueNames -Contains $valueName)) {'+"^""`r`n"^""+' Write-Host ''Skipping, no action needed, registry value does not exist.'''+"^""`r`n"^""+' Exit 0'+"^""`r`n"^""+'}'+"^""`r`n"^""+''+"^""`r`n"^""+''+"^""`r`n"^""+'try {'+"^""`r`n"^""+' if ($valueName -ieq ''(default)'') {'+"^""`r`n"^""+' Write-Host ''Removing the default value.'''+"^""`r`n"^""+' $(Get-Item -LiteralPath $path).OpenSubKey('''', $true).DeleteValue('''')'+"^""`r`n"^""+' } else {'+"^""`r`n"^""+' Remove-ItemProperty `'+"^""`r`n"^""+' -LiteralPath $path `'+"^""`r`n"^""+' -Name $valueName `'+"^""`r`n"^""+' -Force `'+"^""`r`n"^""+' -ErrorAction Stop'+"^""`r`n"^""+' }'+"^""`r`n"^""+' Write-Host ''Successfully removed the registry value.'''+"^""`r`n"^""+'} catch {'+"^""`r`n"^""+' Write-Error "^""Failed to remove the registry value: $($_.Exception.Message)"^""'+"^""`r`n"^""+'} '; Invoke-AsTrustedInstaller $cmd"
- Right click on command prompt to paste it.
- Press Enter to apply remaining code.
Copy restore code
Copy and run the following code to restore changes:
:: Restore the registry value "ProductAppDataPath" in key "HKLM\SOFTWARE\Microsoft\Windows Defender" to its original value
PowerShell -ExecutionPolicy Unrestricted -Command "function Invoke-AsTrustedInstaller($Script) { $principalSid = [System.Security.Principal.SecurityIdentifier]::new('S-1-5-80-956008885-3418522649-1831038044-1853292631-2271478464'); $principalName = $principalSid.Translate([System.Security.Principal.NTAccount]); $streamFile = New-TemporaryFile; $scriptFile = New-TemporaryFile; try { $scriptFile = Rename-Item -LiteralPath $scriptFile -NewName ($scriptFile.BaseName + '.ps1') -Force -PassThru; $Script | Out-File $scriptFile -Encoding UTF8; $taskName = "^""privacy$([char]0x002E)sexy invoke"^""; schtasks.exe /delete /tn $taskName /f 2>&1 | Out-Null; $executionCommand = "^""powershell.exe -ExecutionPolicy Bypass -File '$scriptFile' *>&1 | Out-File -FilePath '$streamFile' -Encoding UTF8"^""; $action = New-ScheduledTaskAction -Execute 'powershell.exe' -Argument "^""-ExecutionPolicy Bypass -Command `"^""$executionCommand`"^"""^""; $settings = New-ScheduledTaskSettingsSet -AllowStartIfOnBatteries -DontStopIfGoingOnBatteries; Register-ScheduledTask -TaskName $taskName -Action $action -Settings $settings -Force -ErrorAction Stop | Out-Null; try { ($scheduleService = New-Object -ComObject Schedule.Service).Connect(); $scheduleService.GetFolder('\').GetTask($taskName).RunEx($null, 0, 0, $principalName) | Out-Null; $timeout = (Get-Date).AddMinutes(5); Write-Host "^""Running as $principalName"^""; while ((Get-ScheduledTaskInfo $taskName).LastTaskResult -eq 267009) { Start-Sleep -Milliseconds 200; if ((Get-Date) -gt $timeout) { Write-Warning 'Skipping: Timeout'; break; }; }; if (($result = (Get-ScheduledTaskInfo $taskName).LastTaskResult) -ne 0) { Write-Error "^""Failed, due to exit code: $result."^""; } } finally { schtasks.exe /delete /tn $taskName /f | Out-Null; }; Get-Content $streamFile } finally { Remove-Item $streamFile, $scriptFile; }; }; $cmd = '$data = ''%PROGRAMDATA%\Microsoft\Windows Defender'''+"^""`r`n"^""+' '+"^""`r`n"^""+' $rawType = ''REG_SZ'''+"^""`r`n"^""+' $rawPath = ''HKLM\SOFTWARE\Microsoft\Windows Defender'''+"^""`r`n"^""+' $value = ''ProductAppDataPath'''+"^""`r`n"^""+' $hive = $rawPath.Split(''\'')[0]'+"^""`r`n"^""+' $path = "^""$($hive):$($rawPath.Substring($hive.Length))"^""'+"^""`r`n"^""+' Write-Host "^""Restoring value ''$value'' at ''$path'' with type ''$rawType'' and value ''$data''."^""'+"^""`r`n"^""+' if (-Not $rawType) {'+"^""`r`n"^""+' throw "^""Internal privacy$([char]0x002E)sexy error: Data type is not provided for data ''$data''."^""'+"^""`r`n"^""+' }'+"^""`r`n"^""+' if (-Not (Test-Path -LiteralPath $path)) {'+"^""`r`n"^""+' try {'+"^""`r`n"^""+' New-Item `'+"^""`r`n"^""+' -Path $path `'+"^""`r`n"^""+' -Force -ErrorAction Stop `'+"^""`r`n"^""+' | Out-Null'+"^""`r`n"^""+' Write-Host ''Successfully created registry key.'''+"^""`r`n"^""+' } catch {'+"^""`r`n"^""+' throw "^""Failed to create registry key: $($_.Exception.Message)"^""'+"^""`r`n"^""+' }'+"^""`r`n"^""+' }'+"^""`r`n"^""+' $currentData = Get-ItemProperty `'+"^""`r`n"^""+' -LiteralPath $path `'+"^""`r`n"^""+' -Name $value `'+"^""`r`n"^""+' -ErrorAction SilentlyContinue `'+"^""`r`n"^""+' | Select-Object -ExpandProperty $value'+"^""`r`n"^""+' if ($currentData -eq $data) {'+"^""`r`n"^""+' Write-Host ''Skipping, no changes required, the registry data is already as expected.'''+"^""`r`n"^""+' Exit 0'+"^""`r`n"^""+' }'+"^""`r`n"^""+' '+"^""`r`n"^""+' try {'+"^""`r`n"^""+' $type = switch ($rawType) {'+"^""`r`n"^""+' ''REG_SZ'' { ''String'' }'+"^""`r`n"^""+' ''REG_DWORD'' { ''DWord'' }'+"^""`r`n"^""+' ''REG_QWORD'' { ''QWord'' }'+"^""`r`n"^""+' ''REG_EXPAND_SZ'' { ''ExpandString'' }'+"^""`r`n"^""+' default {'+"^""`r`n"^""+' throw "^""Internal privacy$([char]0x002E)sexy error: Failed to find data type for: ''$rawType''."^""'+"^""`r`n"^""+' }'+"^""`r`n"^""+' }'+"^""`r`n"^""+' Set-ItemProperty `'+"^""`r`n"^""+' -LiteralPath $path `'+"^""`r`n"^""+' -Name $value `'+"^""`r`n"^""+' -Value $data `'+"^""`r`n"^""+' -Type $type `'+"^""`r`n"^""+' -Force `'+"^""`r`n"^""+' -ErrorAction Stop'+"^""`r`n"^""+' Write-Host ''Successfully restored the registry value.'''+"^""`r`n"^""+' } catch {'+"^""`r`n"^""+' throw "^""Failed to restore the value: $($_.Exception.Message)"^""'+"^""`r`n"^""+' } '; Invoke-AsTrustedInstaller $cmd"
Support
This website relies on your support.
Your donation helps keep the project alive and improves its content ❤️.
Share this page: