Skip to content

Instantly share code, notes, and snippets.

@ishu3101
Created October 4, 2018 22:22
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ishu3101/d76900d513383595bf5e7c8b8afe78c2 to your computer and use it in GitHub Desktop.
Save ishu3101/d76900d513383595bf5e7c8b8afe78c2 to your computer and use it in GitHub Desktop.
Disable User Access Account (UAC) using PowerShell
function Disable-UAC(){
$numVersion = (Get-CimInstance Win32_OperatingSystem).Version
$numSplit = $numVersion.split(".")[0]
if ($numSplit -eq 10) {
Set-ItemProperty "HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Policies\System" -Name "ConsentPromptBehaviorAdmin" -Value "0"
}
elseIf ($numSplit -eq 6) {
$enumSplit = $numSplit.split(".")[1]
if ($enumSplit -eq 1 -or $enumSplit -eq 0) {
Set-ItemProperty "HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Policies\System" -Name "EnableLUA" -Value "0"
} else {
Set-ItemProperty "HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Policies\System" -Name "ConsentPromptBehaviorAdmin" -Value "0"
}
}
elseIf ($numSplit -eq 5) {
Set-ItemProperty "HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Policies\System" -Name "EnableLUA" -Value "0"
}
else {
Set-ItemProperty "HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Policies\System" -Name "ConsentPromptBehaviorAdmin" -Value "0"
}
Write-Host "Successfully Disabled UAC!"
}
@szehoyeu
Copy link

szehoyeu commented Apr 7, 2022

Thank you for sharing.

For Windows 10, I found the registry key values allow you to set different levels from the UAC settings. Here is what I found.

UAC Settings
Control Panel\All Control Panel Items\Security and Maintenance => User Account Control Settings

Registry location:
Computer\HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Policies\System

The following values on "ConsentPromptBehaviorAdmin" and "PromptOnSecureDesktop" for different levels of UAC settings.

"ConsentPromptBehaviorAdmin"
-Value 
    0 : (Not recommended - Lowest) Never notify me when 
                                - "PromptOnSecureDesktop" -Value "0"

    5 : (Not recommended) Notify me only when apps try to make changes to my computer (Do not dim my desktop)
                                - "PromptOnSecureDesktop" -Value "0"

    5 : (Recommended) Notify me only when apps try to make changes to my computer (default)
                                - Don't notify me when I make changes to Windows settings 
                                - "PromptOnSecureDesktop" -Value "1"

    2 : (Recommended - highest level ) Always notify me when:  
                                - Apps try to install software or make changes to my computer 
                                - I make changes to Windows settings
                                - "PromptOnSecureDesktop" -Value "1"

@DennisL68
Copy link

DennisL68 commented Sep 12, 2023

This script makes no sense. UAC was introduced with Windows Vista/Windows Server 2008, i.e. $numSplit -eq 6 -and $enumSplit -eq 0.

Trying to check and change UAC on $numSplit -eq 5 (Windows 2000 to Windows Server 2003 R2) in line 16 ... 18 is useless...

The only special cases the script handles seems to be for 6.0 and 6.1 where the script sets EnableLUA to 0.
In all other cases the script changes ConsentPromptBehaviorAdmin instead...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment