diff --git a/app/AutoUpdate/AutoUpdateControl.cs b/app/AutoUpdate/AutoUpdateControl.cs index ebe876c8..f5ed8d73 100644 --- a/app/AutoUpdate/AutoUpdateControl.cs +++ b/app/AutoUpdate/AutoUpdateControl.cs @@ -83,7 +83,8 @@ async void CheckForUpdatesAsync() versionUrl = url; settings.SetVersionLabel(Properties.Strings.DownloadUpdate + ": " + tag, true); - if (Program.actionParam == "autoupdate") + string[] args = Environment.GetCommandLineArgs(); + if (args.Length > 1 && args[1] == "autoupdate") { AutoUpdate(url); return; @@ -115,7 +116,7 @@ async void CheckForUpdatesAsync() public static string EscapeString(string input) { - return Regex.Replace(input, @"\[|\]", "`$0").Replace("'","''"); + return Regex.Replace(Regex.Replace(input, @"\[|\]", "`$0"), @"\'", "''"); } async void AutoUpdate(string requestUri) @@ -126,6 +127,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 a5581d51..cc309b10 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) { - if (args.Length > 0) actionParam = args[0]; + string action = ""; + if (args.Length > 0) action = args[0]; - if (actionParam == "charge") + if (action == "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('\\') || actionParam.Length > 0) + if (Environment.CurrentDirectory.Trim('\\') == Application.StartupPath.Trim('\\') || action.Length > 0) { SettingsToggle(false); } - switch (actionParam) + switch (action) { case "cpu": Startup.ReScheduleAdmin();