我已经看过这样的线程: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!");
}
慕尼黑8549860
相关分类