mirror of
https://github.com/knah/VRCMelonAssistant.git
synced 2024-05-22 05:12:58 +12:00
Updater didn't actually need admin to work.
This commit is contained in:
parent
f0b09fa948
commit
7a9db95534
|
@ -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;
|
||||
|
|
|
@ -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()
|
||||
|
|
|
@ -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())
|
||||
|
|
Loading…
Reference in a new issue