C# change windows UAC level to Always Notify

2019-08-04 13:23发布

问题:

I want to change the UAC level of the machine to "Always Notify" level which is the top level.

I tried changing the following registry key value to 1. Key = HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Policies\System

const string UACkey = @"HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Policies\System";
            const string Subkey = "EnableLUA";
RegistryUtilities.SetValue(UACkey, Subkey, **1**, Microsoft.Win32.RegistryValueKind.DWord, RegistryUtilities.WOW64Key.Key64);

This result in UAC to be in 3rd level (Notify when programms try to make changes).

How to set it to top level?

回答1:

I managed to find this by changing UAC and having regedit open at the same time, and watching which values changed.

When on the top setting, the value

ConsentPromptBehaviorAdmin

changes to 2, rather than 5 when it's on the 3rd level (nice logic there Microsoft). Changing that value as well as EnableLUA should do it.

Hope this helps



标签: c# registry uac