From 664eaf68b752a6029406d504099452ea1d6c1c05 Mon Sep 17 00:00:00 2001 From: Serge <5920850+seerge@users.noreply.github.com> Date: Wed, 8 Jan 2025 20:25:11 +0100 Subject: [PATCH] Auto Update tweaks https://github.com/seerge/g-helper/issues/3568 --- app/AutoUpdate/AutoUpdateControl.cs | 9 ++++++++- app/Program.cs | 10 +++++----- 2 files changed, 13 insertions(+), 6 deletions(-) diff --git a/app/AutoUpdate/AutoUpdateControl.cs b/app/AutoUpdate/AutoUpdateControl.cs index e8ab0999..f6f66560 100644 --- a/app/AutoUpdate/AutoUpdateControl.cs +++ b/app/AutoUpdate/AutoUpdateControl.cs @@ -83,6 +83,12 @@ async void CheckForUpdatesAsync() versionUrl = url; settings.SetVersionLabel(Properties.Strings.DownloadUpdate + ": " + tag, true); + if (Program.actionParam == "autoupdate") + { + AutoUpdate(url); + return; + } + if (AppConfig.GetString("skip_version") != tag) { DialogResult dialogResult = MessageBox.Show(Properties.Strings.DownloadUpdate + ": G-Helper " + tag + "?", "Update", MessageBoxButtons.YesNo); @@ -109,7 +115,7 @@ async void CheckForUpdatesAsync() public static string EscapeString(string input) { - return Regex.Replace(input, @"\[|\]", "`$0"); + return Regex.Replace(input, @"\[|\]", "`$0").Replace("'","''"); } async void AutoUpdate(string requestUri) @@ -120,6 +126,7 @@ async void AutoUpdate(string requestUri) string exeLocation = Application.ExecutablePath; string exeDir = Path.GetDirectoryName(exeLocation); + exeDir = "C:\\Program Files\\GHelper"; string exeName = Path.GetFileName(exeLocation); string zipLocation = exeDir + "\\" + zipName; diff --git a/app/Program.cs b/app/Program.cs index cc309b10..a5581d51 100644 --- a/app/Program.cs +++ b/app/Program.cs @@ -46,15 +46,15 @@ static class Program public static InputDispatcher? inputDispatcher; private static PowerLineStatus isPlugged = SystemInformation.PowerStatus.PowerLineStatus; + public static string actionParam = ""; // The main entry point for the application public static void Main(string[] args) { - string action = ""; - if (args.Length > 0) action = args[0]; + if (args.Length > 0) actionParam = args[0]; - if (action == "charge") + if (actionParam == "charge") { BatteryLimit(); Application.Exit(); @@ -131,12 +131,12 @@ public static void Main(string[] args) Task task = Task.Run((Action)PeripheralsProvider.DetectAllAsusMice); PeripheralsProvider.RegisterForDeviceEvents(); - if (Environment.CurrentDirectory.Trim('\\') == Application.StartupPath.Trim('\\') || action.Length > 0) + if (Environment.CurrentDirectory.Trim('\\') == Application.StartupPath.Trim('\\') || actionParam.Length > 0) { SettingsToggle(false); } - switch (action) + switch (actionParam) { case "cpu": Startup.ReScheduleAdmin();