为了账号安全,请及时绑定邮箱和手机立即绑定

禁用 UAC 并通知用户

禁用 UAC 并通知用户

C#
凤凰求蛊 2022-07-10 16:05:43
我已经看过这样的线程:Disabling UAC programmatically但是它们有点旧,似乎我做不到。我正在尝试创建一个 Windows 工具来帮助用户执行某些过程(例如启用或禁用 UAC)。到目前为止,这是我的代码,即使管理员正确,它也不会调低或调高 UAC 值。现在我没有使用管理员帐户(Windows 10),但我确实可以访问本地管理员凭据。try        {            RegistryKey uac = Registry.CurrentUser.OpenSubKey("Software\\Microsoft\\Windows\\CurrentVersion\\Policies\\System", true);            if (uac == null)            {                uac = Registry.CurrentUser.CreateSubKey("Software\\Microsoft\\Windows\\CurrentVersion\\Policies\\System");            }            uac.SetValue("EnableLUA", 0);            uac.Close();        }        catch (Exception)        {            MessageBox.Show("Error!");        }
查看完整描述

1 回答

?
慕尼黑8549860

TA贡献1818条经验 获得超11个赞

您在此处使用 Registry.CurrentUser,请改用 LocalMachine。所以代码会是这样的:


RegistryKey uac = Registry.LocalMachine.OpenSubKey("Software\\Microsoft\\Windows\\CurrentVersion\\Policies\\System", true);

                if (uac == null)

                {

                    uac = Registry.LocalMachine.CreateSubKey("Software\\Microsoft\\Windows\\CurrentVersion\\Policies\\System");


                }

                uac.SetValue("EnableLUA", 0);


查看完整回答
反对 回复 2022-07-10
  • 1 回答
  • 0 关注
  • 103 浏览

添加回答

举报

0/150
提交
取消
意见反馈 帮助中心 APP下载
官方微信