以编程方式禁用UAC-更改不会生效吗? [英] Disabling UAC programmatically - Change doesn't take effect?

查看:164
本文介绍了以编程方式禁用UAC-更改不会生效吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我创建了一个C#应用程序,将 EnableLUA键更改为0,
该应用程序以管理员权限运行,并且没有错误弹出:

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);
}

注册表项确实从1更改为0,但是即使重新启动计算机,
UAC仍处于启用状态。然后,当我进入控制面板>用户帐户控制时,滑块被完全调低。当按下保存(并且未进行任何修改)时,UAC似乎被禁用。

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?

推荐答案

UAC不能以编程方式被禁用,旨在防止此类行为发生。 UAC的全部要点是使除用户交互之外的所有其他操作均无法绕过/禁用它。

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.

当然,您可以将注册表项设置为0,然后可以看到滑块移动了,但是除非用户实际上是引起该动作的用户(单击确定进行确认),否则它将不会更新。

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的运行级别较低在操作系统中,您的代码必须在内核级别运行才能禁用UAC,仅以admin身份运行是不够的。而且现代BIOS中的Execute Disable Bit将阻止您的代码通过任何一种方法(例如缓冲区溢出)注入内核。

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)

一个更好的解决方案是检测UAC是否

A better solution would be to detect if UAC is enabled and direct the user on how to turn it off.

除非您想做一些古怪的事情,例如以编程方式打开屏幕以禁用uac并模拟鼠标输入,将滑块向下滑动至无,然后单击确定。

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.

这篇关于以编程方式禁用UAC-更改不会生效吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆