亚洲在线久爱草,狠狠天天香蕉网,天天搞日日干久草,伊人亚洲日本欧美

為了賬號安全,請及時綁定郵箱和手機立即綁定
已解決430363個問題,去搜搜看,總會有你想問的

禁用 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 關注
  • 125 瀏覽

添加回答

舉報

0/150
提交
取消
微信客服

購課補貼
聯系客服咨詢優惠詳情

幫助反饋 APP下載

慕課網APP
您的移動學習伙伴

公眾號

掃描二維碼
關注慕課網微信公眾號