diff --git a/ModAssistant/App.xaml.cs b/ModAssistant/App.xaml.cs index 486a377..a8b7874 100644 --- a/ModAssistant/App.xaml.cs +++ b/ModAssistant/App.xaml.cs @@ -57,9 +57,7 @@ namespace ModAssistant Utils.SendNotify("Invalid argument! '--install' requires an option."); break; - case "--update": - Updater.Run(); - + case "--no-update": MainWindow window = new MainWindow(); window.Show(); break; diff --git a/ModAssistant/Classes/Updater.cs b/ModAssistant/Classes/Updater.cs index a661d82..c2891cc 100644 --- a/ModAssistant/Classes/Updater.cs +++ b/ModAssistant/Classes/Updater.cs @@ -21,7 +21,6 @@ namespace ModAssistant private static Version CurrentVersion; private static Version LatestVersion; private static bool NeedsUpdate = false; - private static bool IsAdmin = new WindowsPrincipal(WindowsIdentity.GetCurrent()).IsInRole(WindowsBuiltInRole.Administrator); public static bool CheckForUpdate() { @@ -56,37 +55,7 @@ namespace ModAssistant Utils.SendNotify("Couldn't check for updates."); } - if (NeedsUpdate) RunUpdate(); - } - - public static void RunUpdate() - { - if (IsAdmin) - { - StartUpdate(); - } - else - { - RestartAsAdmin(); - } - } - - private static void RestartAsAdmin() - { - Process process = new Process(); - process.StartInfo.FileName = ExePath; - process.StartInfo.Arguments = "--update"; - process.StartInfo.UseShellExecute = true; - process.StartInfo.Verb = "runas"; - try - { - process.Start(); - } - catch - { - MessageBox.Show("Mod Assistant Updater needs to run as Admin. Please try again."); - } - App.Current.Shutdown(); + if (NeedsUpdate) StartUpdate(); } public static void StartUpdate() diff --git a/ModAssistant/Classes/Utils.cs b/ModAssistant/Classes/Utils.cs index 55b4258..69434d1 100644 --- a/ModAssistant/Classes/Utils.cs +++ b/ModAssistant/Classes/Utils.cs @@ -11,6 +11,8 @@ using System.Windows; using System.Management; using ModAssistant.Properties; using System.Net; +using System.Diagnostics; +using System.Security.Principal; namespace ModAssistant { @@ -23,6 +25,7 @@ namespace ModAssistant public const string BeatModsURL = "https://beatmods.com"; public const string BeatModsModsOptions = "mod?status=approved"; public const string MD5Spacer = " "; + public static bool IsAdmin = new WindowsPrincipal(WindowsIdentity.GetCurrent()).IsInRole(WindowsBuiltInRole.Administrator); } public static void SendNotify(string message, string title = "Mod Assistant") @@ -40,6 +43,24 @@ namespace ModAssistant notification.Dispose(); } + private static void RestartAsAdmin(string Arguments) + { + Process process = new Process(); + process.StartInfo.FileName = Process.GetCurrentProcess().MainModule.FileName; + process.StartInfo.Arguments = Arguments; + process.StartInfo.UseShellExecute = true; + process.StartInfo.Verb = "runas"; + try + { + process.Start(); + } + catch + { + MessageBox.Show("Mod Assistant Updater needs to run as Admin. Please try again."); + } + App.Current.Shutdown(); + } + public static string CalculateMD5(string filename) { using (var md5 = MD5.Create())