From 00dc6a6ca3aa64b23557ae1cfdc29646acb25248 Mon Sep 17 00:00:00 2001 From: Serge <5920850+seerge@users.noreply.github.com> Date: Fri, 12 Jan 2024 19:35:10 +0100 Subject: [PATCH] Auto updater tweaks --- app/AppConfig.cs | 5 +++ app/AsusACPI.cs | 5 +++ app/AutoUpdate/AutoUpdateControl.cs | 4 ++- app/GHelper.csproj | 2 +- app/Helpers/OptimizationService.cs | 53 +---------------------------- 5 files changed, 15 insertions(+), 54 deletions(-) diff --git a/app/AppConfig.cs b/app/AppConfig.cs index 8bd990b4..5a2555f5 100644 --- a/app/AppConfig.cs +++ b/app/AppConfig.cs @@ -490,6 +490,11 @@ public static class AppConfig return ContainsModel("FA507"); } + public static bool IsIntelHX() + { + return ContainsModel("G814") || ContainsModel("G614") || ContainsModel("G834") || ContainsModel("G634"); + } + public static bool IsASUS() { return ContainsModel("ROG") || ContainsModel("TUF") || ContainsModel("Vivobook") || ContainsModel("Zenbook"); diff --git a/app/AsusACPI.cs b/app/AsusACPI.cs index f7ca78dc..effd6c04 100644 --- a/app/AsusACPI.cs +++ b/app/AsusACPI.cs @@ -259,6 +259,11 @@ public class AsusACPI DefaultTotal = 30; } + if (AppConfig.IsIntelHX()) + { + MaxTotal = 175; + } + if (AppConfig.DynamicBoost5()) { MaxGPUBoost = 5; diff --git a/app/AutoUpdate/AutoUpdateControl.cs b/app/AutoUpdate/AutoUpdateControl.cs index 8c60a0a2..42093c87 100644 --- a/app/AutoUpdate/AutoUpdateControl.cs +++ b/app/AutoUpdate/AutoUpdateControl.cs @@ -1,4 +1,5 @@ -using System.Diagnostics; +using GHelper.Helpers; +using System.Diagnostics; using System.Net; using System.Reflection; using System.Text.Json; @@ -130,6 +131,7 @@ namespace GHelper.AutoUpdate cmd.StartInfo.CreateNoWindow = true; cmd.StartInfo.FileName = "powershell"; cmd.StartInfo.Arguments = command; + if (ProcessHelper.IsUserAdministrator()) cmd.StartInfo.Verb = "runas"; cmd.Start(); } catch (Exception ex) diff --git a/app/GHelper.csproj b/app/GHelper.csproj index baba1abe..716523d1 100644 --- a/app/GHelper.csproj +++ b/app/GHelper.csproj @@ -15,7 +15,7 @@ AnyCPU False True - 0.146 + 0.100 diff --git a/app/Helpers/OptimizationService.cs b/app/Helpers/OptimizationService.cs index 8ab7b314..18218b1e 100644 --- a/app/Helpers/OptimizationService.cs +++ b/app/Helpers/OptimizationService.cs @@ -1,7 +1,4 @@ -using Microsoft.Win32; -using System.Diagnostics; -using System.Text; -using System.Text.RegularExpressions; +using System.Diagnostics; namespace GHelper.Helpers { @@ -21,35 +18,6 @@ namespace GHelper.Helpers "AsusCertService" }; - public static void SetChargeLimit(int newValue) - { - // Set the path to the .ini file - string path = @"C:\ProgramData\ASUS\ASUS System Control Interface\ASUSOptimization\Customization.ini"; - - - // Make a backup copy of the INI file - string backupPath = path + ".bak"; - File.Copy(path, backupPath, true); - - string fileContents = File.ReadAllText(path, Encoding.Unicode); - - // Find the section [BatteryHealthCharging] - string sectionPattern = @"\[BatteryHealthCharging\]\s*(version=\d+)?\s+value=(\d+)"; - Match sectionMatch = Regex.Match(fileContents, sectionPattern); - if (sectionMatch.Success) - { - // Replace the value with the new value - string oldValueString = sectionMatch.Groups[2].Value; - int oldValue = int.Parse(oldValueString); - string newSection = sectionMatch.Value.Replace($"value={oldValue}", $"value={newValue}"); - - // Replace the section in the file contents - fileContents = fileContents.Replace(sectionMatch.Value, newSection); - - File.WriteAllText(path, fileContents, Encoding.Unicode); - } - } - public static bool IsRunning() { return Process.GetProcessesByName("AsusOptimization").Count() > 0; @@ -72,25 +40,6 @@ namespace GHelper.Helpers } - public static void SetBacklightOffDelay(int value = 60) - { - try - { - RegistryKey myKey = Registry.LocalMachine.OpenSubKey(@"SOFTWARE\ASUS\ASUS System Control Interface\AsusOptimization\ASUS Keyboard Hotkeys", true); - if (myKey != null) - { - myKey.SetValue("TurnOffKeybdLight", value, RegistryValueKind.DWord); - myKey.Close(); - } - } - catch (Exception ex) - { - Logger.WriteLine(ex.Message); - } - } - - - public static void StopAsusServices() { foreach (string service in services)