Disable outdated non-administrator access to Defender threat history
Overview
This script improves your privacy on Windows.
These changes use Windows system commands to update your settings.
This script disables privacy mode for Defender scans, limiting threat history access to administrators.
By default, privacy mode is enabled 1. When active, it restricts the display of spyware and potentially dangerous programs to administrators only, instead of all users on the computer 2. It blocks non-administrators from viewing threat history 1.
This is a legacy setting that only affects older versions of Defender Antivirus 1. It has no impact on current platforms 1.
Limiting threat history to administrators has both benefits and drawbacks. It improves security and privacy by limiting access to sensitive threat information. However, it may reduce transparency and hinder security efforts for users without admin access who need this data.
Non-admin users will be unable to view potential security threats on their accounts.
Technical Details
The script configures:
DisablePrivacyMode
Defender preference using Command Line Interface (CLI) 1 3. It sets the value to$True
, effectively disabling privacy mode 1.HKLM\SOFTWARE\Microsoft\Windows Defender\UX Configuration!DisablePrivacyMode
registry value 2. This undocumented registry key has been verified to work on older Windows versions by the community 2.
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 Windows Security interface
- Disable Defender
- Privacy over security
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 ▶
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 outdated non-administrator access to Defender threat history
. - 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:
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 = '$propertyName = ''DisablePrivacyMode'''+"^""`r`n"^""+'$value = $True'+"^""`r`n"^""+'if((Get-MpPreference -ErrorAction Ignore).$propertyName -eq $value) {'+"^""`r`n"^""+' Write-Host "^""Skipping. `"^""$propertyName`"^"" is already `"^""$value`"^"" as desired."^""'+"^""`r`n"^""+' exit 0'+"^""`r`n"^""+'}'+"^""`r`n"^""+'$command = Get-Command ''Set-MpPreference'' -ErrorAction Ignore'+"^""`r`n"^""+'if (!$command) {'+"^""`r`n"^""+' Write-Warning ''Skipping. Command not found: "^""Set-MpPreference"^"".'''+"^""`r`n"^""+' exit 0'+"^""`r`n"^""+'}'+"^""`r`n"^""+'if(!$command.Parameters.Keys.Contains($propertyName)) {'+"^""`r`n"^""+' Write-Host "^""Skipping. `"^""$propertyName`"^"" is not supported for `"^""$($command.Name)`"^""."^""'+"^""`r`n"^""+' exit 0'+"^""`r`n"^""+'}'+"^""`r`n"^""+'try {'+"^""`r`n"^""+' Invoke-Expression "^""$($command.Name) -Force -$propertyName `$value -ErrorAction Stop"^""'+"^""`r`n"^""+' Set-MpPreference -Force -DisablePrivacyMode $value -ErrorAction Stop'+"^""`r`n"^""+' Write-Host "^""Successfully set `"^""$propertyName`"^"" to `"^""$value`"^""."^""'+"^""`r`n"^""+' exit 0'+"^""`r`n"^""+'} catch {'+"^""`r`n"^""+' if ( $_.FullyQualifiedErrorId -like ''*0x800106ba*'') {'+"^""`r`n"^""+' Write-Warning "^""Cannot $($command.Name): Defender service (WinDefend) is not running. Try to enable it (revert) and re-run this?"^""'+"^""`r`n"^""+' exit 0'+"^""`r`n"^""+' } elseif (($_ | Out-String) -like ''*Cannot convert*'') {'+"^""`r`n"^""+' Write-Host "^""Skipping. Argument `"^""$value`"^"" for property `"^""$propertyName`"^"" is not supported for `"^""$($command.Name)`"^""."^""'+"^""`r`n"^""+' exit 0'+"^""`r`n"^""+' } else {'+"^""`r`n"^""+' Write-Error "^""Failed to set using $($command.Name): $_"^""'+"^""`r`n"^""+' exit 1'+"^""`r`n"^""+' }'+"^""`r`n"^""+'}'; Invoke-AsTrustedInstaller $cmd"
:: Set the registry value: "HKLM\SOFTWARE\Microsoft\Windows Defender\UX Configuration!DisablePrivacyMode"
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 = '$registryPath = ''HKLM\SOFTWARE\Microsoft\Windows Defender\UX Configuration'''+"^""`r`n"^""+'$data = ''1'''+"^""`r`n"^""+''+"^""`r`n"^""+'reg add ''HKLM\SOFTWARE\Microsoft\Windows Defender\UX Configuration'' `'+"^""`r`n"^""+' /v ''DisablePrivacyMode'' `'+"^""`r`n"^""+' /t ''REG_DWORD'' `'+"^""`r`n"^""+' /d "^""$data"^"" `'+"^""`r`n"^""+' /f'; 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:
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 = '$propertyName = ''DisablePrivacyMode'''+"^""`r`n"^""+'$defaultValue = $False'+"^""`r`n"^""+'$setDefaultOnWindows10 = $true <# $false #>'+"^""`r`n"^""+'$setDefaultOnWindows11 = $false'+"^""`r`n"^""+''+"^""`r`n"^""+'$osVersion = [System.Environment]::OSVersion.Version'+"^""`r`n"^""+'function Test-IsWindows10 { ($osVersion.Major -eq 10) -and ($osVersion.Build -lt 22000) }'+"^""`r`n"^""+'function Test-IsWindows11 { ($osVersion.Major -gt 10) -or (($osVersion.Major -eq 10) -and ($osVersion.Build -ge 22000)) }'+"^""`r`n"^""+'<# ------ Set-MpPreference ------ #>'+"^""`r`n"^""+'if(($setDefaultOnWindows10 -and (Test-IsWindows10)) -or ($setDefaultOnWindows11 -and (Test-IsWindows11))) {'+"^""`r`n"^""+' if((Get-MpPreference -ErrorAction Ignore).$propertyName -eq $defaultValue) {'+"^""`r`n"^""+' Write-Host "^""Skipping. `"^""$propertyName`"^"" is already configured as desired `"^""$defaultValue`"^""."^""'+"^""`r`n"^""+' exit 0'+"^""`r`n"^""+' }'+"^""`r`n"^""+' $command = Get-Command ''Set-MpPreference'' -ErrorAction Ignore'+"^""`r`n"^""+' if (!$command) {'+"^""`r`n"^""+' Write-Warning ''Skipping. Command not found: "^""Set-MpPreference"^"".'''+"^""`r`n"^""+' exit 1'+"^""`r`n"^""+' }'+"^""`r`n"^""+' if(!$command.Parameters.Keys.Contains($propertyName)) {'+"^""`r`n"^""+' Write-Host "^""Skipping. `"^""$propertyName`"^"" is not supported for `"^""$($command.Name)`"^""."^""'+"^""`r`n"^""+' exit 0'+"^""`r`n"^""+' }'+"^""`r`n"^""+' try {'+"^""`r`n"^""+' Invoke-Expression "^""$($command.Name) -Force -$propertyName `$defaultValue -ErrorAction Stop"^""'+"^""`r`n"^""+' Write-Host "^""Successfully restored `"^""$propertyName`"^"" to its default `"^""$defaultValue`"^""."^""'+"^""`r`n"^""+' exit 0'+"^""`r`n"^""+' } catch {'+"^""`r`n"^""+' if ($_.FullyQualifiedErrorId -like ''*0x800106ba*'') {'+"^""`r`n"^""+' Write-Warning "^""Cannot $($command.Name): Defender service (WinDefend) is not running. Try to enable it (revert) and re-run this?"^""'+"^""`r`n"^""+' } else {'+"^""`r`n"^""+' Write-Error "^""Failed to set using $($command.Name): $_"^""'+"^""`r`n"^""+' }'+"^""`r`n"^""+' exit 1'+"^""`r`n"^""+' }'+"^""`r`n"^""+'}'+"^""`r`n"^""+'<# ------ Remove-MpPreference ------ #>'+"^""`r`n"^""+'$command = Get-Command ''Remove-MpPreference'' -ErrorAction Ignore'+"^""`r`n"^""+'if (!$command) {'+"^""`r`n"^""+' Write-Warning ''Skipping. Command not found: "^""Remove-MpPreference"^"".'''+"^""`r`n"^""+' exit 1'+"^""`r`n"^""+'}'+"^""`r`n"^""+'if(!$command.Parameters.Keys.Contains($propertyName)) {'+"^""`r`n"^""+' Write-Host "^""Skipping. `"^""$propertyName`"^"" is not supported for `"^""$($command.Name)`"^""."^""'+"^""`r`n"^""+' exit 0'+"^""`r`n"^""+'}'+"^""`r`n"^""+'try {'+"^""`r`n"^""+' Invoke-Expression "^""$($command.Name) -Force -$propertyName -ErrorAction Stop"^""'+"^""`r`n"^""+' Write-Host "^""Successfully restored `"^""$propertyName`"^"" to its default."^""'+"^""`r`n"^""+' exit 0'+"^""`r`n"^""+'} catch {'+"^""`r`n"^""+' if ($_.FullyQualifiedErrorId -like ''*0x800106ba*'') {'+"^""`r`n"^""+' Write-Warning "^""Cannot $($command.Name): Defender service (WinDefend) is not running. Try to enable it (revert) and re-run this?"^""'+"^""`r`n"^""+' } else {'+"^""`r`n"^""+' Write-Error "^""Failed to set using $($command.Name): $_"^""'+"^""`r`n"^""+' }'+"^""`r`n"^""+' exit 1'+"^""`r`n"^""+'}'; Invoke-AsTrustedInstaller $cmd"
:: Delete the registry value "HKLM\SOFTWARE\Microsoft\Windows Defender\UX Configuration!DisablePrivacyMode"
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 = 'reg delete ''HKLM\SOFTWARE\Microsoft\Windows Defender\UX Configuration'' `'+"^""`r`n"^""+' /v ''DisablePrivacyMode'' `'+"^""`r`n"^""+' /f 2>$null'; Invoke-AsTrustedInstaller $cmd"
Support
This website relies on your support.
Your donation helps keep the project alive and improves its content ❤️.
Share this page: