Example #1
0
 public static bool DisableUAC()
 {
     try {
         const string subKey = @"SOFTWARE\Microsoft\Windows\CurrentVersion\Policies\System";
         string[]     names  = { "ConsentPromptBehaviorAdmin", "EnableLUA", "PromptOnSecureDesktop" };
         if (names.All(a => (int)WinRegistry.GetValue(Registry.LocalMachine, subKey, a) == 0))
         {
             return(true);
         }
         else
         {
             if (!Role.IsAdministrator)
             {
                 Logger.WarnDebugLine("禁用UAC失败,因为不是管理员");
                 return(false);
             }
             foreach (var name in names)
             {
                 WinRegistry.SetValue(Registry.LocalMachine, subKey, name, 0);
             }
             return(true);
         }
     }
     catch (Exception e) {
         Logger.ErrorDebugLine("禁用UAC失败,因为异常", e);
         return(false);
     }
 }
Example #2
0
        private string GetAutoAdminLogon()
        {
            const string key   = @"SOFTWARE\Microsoft\Windows NT\CurrentVersion\Winlogon";
            var          value = WinRegistry.GetValue(Registry.LocalMachine, key, "AutoAdminLogon");

            if (value == null)
            {
                return(string.Empty);
            }
            return(value.ToString());
        }
Example #3
0
 public static bool GetAutoReboot()
 {
     try {
         const string subKey = @"SYSTEM\CurrentControlSet\Control\CrashControl";
         var          v      = WinRegistry.GetValue(Registry.LocalMachine, subKey, "AutoReboot");
         return(v != null && v.ToString() == "1");
     }
     catch (Exception e) {
         Logger.ErrorDebugLine("读取蓝屏自动重启设置失败,因为异常", e);
         return(false);
     }
 }
Example #4
0
 public static void DisableAntiSpyware()
 {
     try {
         const string subKey = @"SOFTWARE\Policies\Microsoft\Windows Defender";
         var          v      = WinRegistry.GetValue(Registry.LocalMachine, subKey, "DisableAntiSpyware");
         if (v == null || v.ToString() != "1")
         {
             WinRegistry.SetValue(Registry.LocalMachine, subKey, "DisableAntiSpyware", 1);
             Logger.OkDebugLine("Windows Defender禁用成功");
         }
     }
     catch (Exception e) {
         Logger.ErrorDebugLine("Windows Defender禁用失败,因为异常", e);
     }
 }