예제 #1
0
        public static void RunNTMinerServices(Action callback)
        {
            string processName = "NTMinerServices";

            Process[] processes = Process.GetProcessesByName(processName);
            if (processes.Length != 0)
            {
                Server.ControlCenterService.GetServicesVersionAsync((thatVersion, exception) => {
                    try {
                        string thisVersion = ThisNTMinerServicesFileVersion;
                        if (thatVersion != thisVersion)
                        {
                            Logger.InfoDebugLine($"发现新版NTMinerServices:{thatVersion}->{thisVersion}");
                            Server.ControlCenterService.CloseServices();
                            System.Threading.Thread.Sleep(1000);
                            Windows.TaskKill.Kill(processName, waitForExit: true);
                            ExtractRunNTMinerServicesAsync(callback);
                        }
                        else
                        {
                            callback?.Invoke();
                        }
                    }
                    catch (Exception e) {
                        Logger.ErrorDebugLine(e);
                        VirtualRoot.ThisLocalError(nameof(NTMinerServicesUtil), "启动失败,请重试,如果问题一直持续请联系开发者解决问题", toConsole: true);
                    }
                });
            }
            else
            {
                ExtractRunNTMinerServicesAsync(callback);
            }
        }
예제 #2
0
 public static void Win10Optimize()
 {
     try {
         Task.Factory.StartNew(() => {
             Type type           = typeof(WindowsUtil);
             Assembly assembly   = type.Assembly;
             string name         = "Win10Optimize.reg";
             string fileFullName = Path.Combine(MainAssemblyInfo.TempDirFullName, name);
             assembly.ExtractManifestResource(type, name, fileFullName);
             Cmd.RunClose("regedit", $"/s \"{fileFullName}\"", waitForExit: true);
             VirtualRoot.ThisLocalInfo(nameof(WindowsUtil), "优化Windows成功", OutEnum.Success);
         });
     }
     catch (Exception e) {
         Logger.ErrorDebugLine(e);
         VirtualRoot.ThisLocalError(nameof(WindowsUtil), "优化Windows失败", OutEnum.Warn);
     }
 }
예제 #3
0
 public static void BlockWAU()
 {
     try {
         Task.Factory.StartNew(() => {
             Type type           = typeof(WindowsUtil);
             Assembly assembly   = type.Assembly;
             string name         = "BlockWAU.bat";
             string fileFullName = Path.Combine(MainAssemblyInfo.TempDirFullName, name);
             assembly.ExtractManifestResource(type, name, fileFullName);
             Cmd.RunClose(fileFullName, string.Empty, waitForExit: true);
             VirtualRoot.ThisLocalInfo(nameof(WindowsUtil), "禁用windows系统更新成功", OutEnum.Success);
         });
     }
     catch (Exception e) {
         VirtualRoot.ThisLocalError(nameof(WindowsUtil), "禁用windows系统更新失败", OutEnum.Warn);
         Logger.ErrorDebugLine(e);
     }
 }