Reputation: 325
I created a C# application that changes the "EnableLUA" key to 0, the application is run with admin rights, and no errors pop up:
//Runs with admin rights
try
{
RegistryKey key =
Registry.LocalMachine.OpenSubKey(@"SOFTWARE\Microsoft\Windows\CurrentVersion\Policies\System", true);
key.SetValue("EnableLUA", "0");
key.Close();
}
catch(Exception e)
{
MessageBox.Show("Error: " + e);
}
The registry key indeed gets changed from 1 to 0, but even after restarting the computer, UAC is still enabled. Then when I go to Control Panel > User Account Control, the slider is turned all the way down. When pressing "Save" (and not having modified anything), UAC suddenly seems to be disabled.
Would this be a bug of some sort or just a weird kind of security? Is there any way around this?
Upvotes: 3
Views: 10471
Reputation: 1
Despite the UAC warning that it only works after OK, this was not the behavior, windows assumed the change and disabled UAC, I tested it and it was the lack of DWORD in WINDOWS 10
Upvotes: 0
Reputation:
You are changing the 32bit DWORD to a string value and therefore it doesn't work
It is absolutley possible to disable uac if you just specify the valuekind to a dword like this
key.SetValue("EnableLUA", "0", RegistryValueKind.DWord);
note that you also need to run program as administrator for the program to acces hklm (HKEY_LOCAL_MACHINE) in regedit
Tested in windows 10 and it works, i do not know if it works in win7 but let me know if it does
Upvotes: 0
Reputation: 171
This version works:
Reference:
using System.Management.Automation;
Code:
var script = PowerShell.Create();
script.AddScript("Set-ItemProperty \"HKLM:\\SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Policies\\System\" -Name \"ConsentPromptBehaviorAdmin\" -Value \"0\" ");
script.Invoke();
Upvotes: 2
Reputation: 7
You can simply Remove the UAC prompt by writing two line of code,
string UAC_key = @"HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Policies\System";
Registry.SetValue(UAC_key, "EnableLUA", 0);`
Upvotes: -1
Reputation: 5357
UAC can't be disabled programatically, it's designed to prevent such an act. The whole point to UAC was to make it impossible for anything other than user interaction to bypass/disable it.
Sure, you can set the registry key to 0, and you can see the slider moved, but unless the user is actually the one causing that action (commiting it with OK) it won't update.
UAC operates at a low level of the OS, your code would have to be running in the kernel level to be able to disable UAC, running as admin isn't enough. And Execute Disable Bit in modern bios's will prevent your code from injecting into the kernel with any kind of method (e.g. buffer overflows)
A better solution would be to detect if UAC is enabled and direct the user on how to turn it off.
Unless you want to do something really wacky, like programatically open the screen to disable uac and simulate mouse input to click the slider down to none and click ok.
Upvotes: 4