示例#1
0
文件: UAC.cs 项目: zylx0532/NtMiner
 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);
     }
 }
示例#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());
        }
示例#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);
     }
 }
示例#4
0
        public void SetAutoLogon(string defaultUserName, string defaultPassword)
        {
            if (!IsGEWindows2004)
            {
                return;
            }
            const string subkey = @"SOFTWARE\Microsoft\Windows NT\CurrentVersion\Winlogon";

            WinRegistry.SetValue(Registry.LocalMachine, subkey, "DefaultUserName", defaultUserName);
            WinRegistry.SetValue(Registry.LocalMachine, subkey, "DefaultPassword", defaultPassword);
            WinRegistry.SetValue(Registry.LocalMachine, subkey, "AutoAdminLogon", "1");
        }
示例#5
0
        public static void SetAutoReboot(bool autoReboot)
        {
            int value = autoReboot ? 1 : 0;

            try {
                const string subKey = @"SYSTEM\CurrentControlSet\Control\CrashControl";
                WinRegistry.SetValue(Registry.LocalMachine, subKey, "AutoReboot", value);
                Logger.OkDebugLine($"{(autoReboot ? "启用" : "禁用")}蓝屏自动重启成功");
            }
            catch (Exception e) {
                Logger.ErrorDebugLine("蓝屏自动重启设置失败,因为异常", e);
            }
        }
示例#6
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);
     }
 }
示例#7
0
 public static bool DisableWindowsErrorUI()
 {
     try {
         const string subKey = @"Software\Microsoft\Windows\Windows Error Reporting";
         string[]     keys   = { "Disabled", "DontShowUI", "LoggingDisabled", "DontSendAdditionalData" };
         foreach (var key in keys)
         {
             WinRegistry.SetValue(Registry.CurrentUser, subKey, key, 1);
         }
         Logger.OkDebugLine("disable windows erro ok");
         return(true);
     }
     catch (Exception e) {
         Logger.ErrorDebugLine("disable windows erro failed,因为异常", e);
         return(false);
     }
 }
示例#8
0
文件: Cmd.cs 项目: GangDang/ntminer
        /// <summary>
        /// 在Windows右键上下文菜单中添加“命令行”菜单
        /// </summary>
        public static void RegCmdHere()
        {
            string cmdHere          = "SOFTWARE\\Classes\\Directory\\background\\shell\\cmd_here";
            string cmdHereCommand   = cmdHere + "\\command";
            string cmdPrompt        = "SOFTWARE\\Classes\\Folder\\shell\\cmdPrompt";
            string cmdPromptCommand = cmdPrompt + "\\command";

            WinRegistry.SetValue(Registry.LocalMachine, cmdHere, "", "命令行");
            WinRegistry.SetValue(Registry.LocalMachine, cmdHere, "Icon", "cmd.exe");
            WinRegistry.SetValue(Registry.LocalMachine, cmdHereCommand, "", "\"cmd.exe\"");
            WinRegistry.SetValue(Registry.LocalMachine, cmdPrompt, "", "命令行");
            WinRegistry.SetValue(Registry.LocalMachine, cmdPromptCommand, "", "\"cmd.exe\" \"cd %1\"");
            cmdHere        = "SOFTWARE\\Classes\\Directory\\shell\\cmd_here";
            cmdHereCommand = cmdHere + "\\command";
            WinRegistry.SetValue(Registry.LocalMachine, cmdHere, "", "命令行");
            WinRegistry.SetValue(Registry.LocalMachine, cmdHere, "Icon", "cmd.exe");
            WinRegistry.SetValue(Registry.LocalMachine, cmdHereCommand, "", "\"cmd.exe\"");
        }
示例#9
0
        /// <summary>
        /// 在Windows Directory和Folder右键上下文菜单中添加“命令行”菜单
        /// </summary>
        public static void RegCmdHere()
        {
            try {
                string cmdHereCommand0 = _cmdHere0 + "\\command";
                WinRegistry.SetValue(Registry.LocalMachine, _cmdHere0, "", "命令行");
                WinRegistry.SetValue(Registry.LocalMachine, _cmdHere0, "Icon", "cmd.exe");
                WinRegistry.SetValue(Registry.LocalMachine, cmdHereCommand0, "", "\"cmd.exe\"");

                string cmdHereCommand1 = _cmdHere1 + "\\command";
                WinRegistry.SetValue(Registry.LocalMachine, _cmdHere1, "", "命令行");
                WinRegistry.SetValue(Registry.LocalMachine, _cmdHere1, "Icon", "cmd.exe");
                WinRegistry.SetValue(Registry.LocalMachine, cmdHereCommand1, "", "\"cmd.exe\"");

                string cmdPromptCommand = _cmdPrompt + "\\command";
                WinRegistry.SetValue(Registry.LocalMachine, _cmdPrompt, "", "命令行");
                WinRegistry.SetValue(Registry.LocalMachine, cmdPromptCommand, "", "\"cmd.exe\" \"cd %1\"");
            }
            catch (Exception e) {
                Logger.ErrorDebugLine(e);
            }
        }