Skip to content

Commit

Permalink
Updated silent update
Browse files Browse the repository at this point in the history
  • Loading branch information
valnoxy committed Dec 26, 2024
1 parent d40a66a commit 2c13b22
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 10 deletions.
40 changes: 31 additions & 9 deletions GoAwayEdge/App.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -47,11 +47,11 @@ public void Application_Startup(object sender, StartupEventArgs e)
case 1 when args.Contains("--debug"):
{
if (args.Contains("--debug"))
IsDebug = true;
IsDebug = true;
if (IsAdministrator() == false)
{
ElevateAsAdmin();
Environment.Exit(0);
Environment.Exit(740);
return;
}

Expand All @@ -71,15 +71,15 @@ public void Application_Startup(object sender, StartupEventArgs e)
if (IsAdministrator() == false)
{
ElevateAsAdmin(string.Join(" ", args));
Environment.Exit(0);
Environment.Exit(740);
return;
}

// Check if user allowed opening the control panel
if (RegistryConfig.GetKey("ControlPanelIsInstalled") != "True")
{
Logging.Log("Control Panel is not allowed on this system, exiting ...", Logging.LogLevel.ERROR);
Environment.Exit(0);
Environment.Exit(1);
return;
}

Expand Down Expand Up @@ -111,6 +111,8 @@ public void Application_Startup(object sender, StartupEventArgs e)

if (args.Contains("-s")) // Silent Installation
{
Configuration.InitialEnvironment();

foreach (var arg in args)
{
if (arg.StartsWith("-e:"))
Expand Down Expand Up @@ -146,22 +148,21 @@ public void Application_Startup(object sender, StartupEventArgs e)

if (IsAdministrator() == false)
{
ElevateAsAdmin(string.Join(" ", args));
Environment.Exit(0);
var elevatedProcess = ElevateAndWait(string.Join(" ", args));
Environment.Exit(elevatedProcess);
return;
}

Configuration.InstallControlPanel = true;
Configuration.InitialEnvironment();
var result = InstallRoutine.Install(null);
Environment.Exit(result);
}
if (args.Contains("-u"))
{
if (IsAdministrator() == false)
{
ElevateAsAdmin(string.Join(" ", args));
Environment.Exit(0);
var elevatedProcess = ElevateAndWait(string.Join(" ", args));
Environment.Exit(elevatedProcess);
return;
}
var result = InstallRoutine.Uninstall(null);
Expand Down Expand Up @@ -236,7 +237,10 @@ public void Application_Startup(object sender, StartupEventArgs e)
ifeoMessageUi.ShowDialog();

if (ifeoMessageUi.Summary == "Btn1")
{
ElevateAsAdmin("--update");
Environment.Exit(740);
}

Environment.Exit(0);
}
Expand Down Expand Up @@ -269,6 +273,24 @@ private static void ElevateAsAdmin(string? arguments = null)
Process.Start(startInfo);
}

private static int ElevateAndWait(string? arguments = null)
{
// Restart program and run as admin
var exeName = Process.GetCurrentProcess().MainModule?.FileName;
if (exeName == null) return -1;
var startInfo = new ProcessStartInfo(exeName)
{
Verb = "runas",
UseShellExecute = true,
Arguments = arguments
};
var p = new Process();
p.StartInfo = startInfo;
p.Start();
p.WaitForExit();
return p.ExitCode;
}

private static string? ParseCustomUrl(string argument, int count)
{
var argParsed = argument.Remove(0, count);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ https://go.microsoft.com/fwlink/?LinkID=208121.
-->
<Project>
<PropertyGroup>
<History>True|2024-12-26T14:22:32.4690057Z||;True|2024-12-26T15:09:04.1027404+01:00||;True|2024-12-26T15:03:19.0005711+01:00||;True|2024-12-25T17:22:09.8471194+01:00||;True|2024-08-13T19:39:30.3814052+02:00||;True|2024-08-13T19:35:07.3638159+02:00||;True|2024-08-13T01:10:27.4137217+02:00||;True|2024-08-13T01:06:17.9215774+02:00||;True|2024-08-13T00:56:54.4657665+02:00||;True|2024-08-13T00:49:21.1156303+02:00||;True|2024-08-13T00:45:56.3970427+02:00||;True|2024-08-13T00:25:23.5481220+02:00||;True|2024-08-12T22:11:19.4188626+02:00||;True|2024-08-12T22:10:38.2923046+02:00||;True|2024-08-12T22:08:45.6517147+02:00||;True|2024-07-30T00:22:22.2984409+02:00||;True|2024-07-30T00:18:17.4366719+02:00||;True|2024-07-30T00:17:49.8084336+02:00||;True|2024-07-22T18:41:59.8117684+02:00||;True|2024-06-18T00:28:22.3138517+02:00||;True|2024-06-18T00:16:46.9788815+02:00||;True|2024-06-09T20:14:23.6305404+02:00||;True|2024-06-09T19:02:49.2570274+02:00||;True|2024-06-09T18:47:29.9573023+02:00||;True|2024-06-09T18:46:39.8011527+02:00||;False|2024-06-09T18:46:05.6633541+02:00||;False|2024-06-09T18:45:59.2563619+02:00||;True|2024-02-18T17:16:27.0408261+01:00||;True|2024-02-18T17:15:41.3961034+01:00||;True|2024-02-18T17:11:58.7761728+01:00||;True|2024-02-18T17:08:57.9390623+01:00||;True|2024-02-18T17:08:26.6377454+01:00||;True|2024-02-18T17:07:45.2050537+01:00||;True|2024-02-18T17:05:12.7495146+01:00||;True|2024-02-18T17:02:32.4549017+01:00||;True|2024-02-18T16:48:25.3074382+01:00||;True|2023-10-19T00:00:28.0962969+02:00||;True|2022-11-13T02:33:03.7406004+01:00||;True|2022-11-13T02:19:07.9073988+01:00||;True|2022-11-13T02:18:35.3043045+01:00||;True|2022-11-12T20:05:07.6366825+01:00||;False|2022-11-12T20:04:52.3576134+01:00||;True|2022-11-12T19:36:12.8480978+01:00||;</History>
<History>True|2024-12-26T17:33:52.9873568Z||;True|2024-12-26T18:31:07.1677995+01:00||;True|2024-12-26T17:03:19.1985996+01:00||;True|2024-12-26T16:24:41.8789667+01:00||;True|2024-12-26T15:22:32.4690057+01:00||;True|2024-12-26T15:09:04.1027404+01:00||;True|2024-12-26T15:03:19.0005711+01:00||;True|2024-12-25T17:22:09.8471194+01:00||;True|2024-08-13T19:39:30.3814052+02:00||;True|2024-08-13T19:35:07.3638159+02:00||;True|2024-08-13T01:10:27.4137217+02:00||;True|2024-08-13T01:06:17.9215774+02:00||;True|2024-08-13T00:56:54.4657665+02:00||;True|2024-08-13T00:49:21.1156303+02:00||;True|2024-08-13T00:45:56.3970427+02:00||;True|2024-08-13T00:25:23.5481220+02:00||;True|2024-08-12T22:11:19.4188626+02:00||;True|2024-08-12T22:10:38.2923046+02:00||;True|2024-08-12T22:08:45.6517147+02:00||;True|2024-07-30T00:22:22.2984409+02:00||;True|2024-07-30T00:18:17.4366719+02:00||;True|2024-07-30T00:17:49.8084336+02:00||;True|2024-07-22T18:41:59.8117684+02:00||;True|2024-06-18T00:28:22.3138517+02:00||;True|2024-06-18T00:16:46.9788815+02:00||;True|2024-06-09T20:14:23.6305404+02:00||;True|2024-06-09T19:02:49.2570274+02:00||;True|2024-06-09T18:47:29.9573023+02:00||;True|2024-06-09T18:46:39.8011527+02:00||;False|2024-06-09T18:46:05.6633541+02:00||;False|2024-06-09T18:45:59.2563619+02:00||;True|2024-02-18T17:16:27.0408261+01:00||;True|2024-02-18T17:15:41.3961034+01:00||;True|2024-02-18T17:11:58.7761728+01:00||;True|2024-02-18T17:08:57.9390623+01:00||;True|2024-02-18T17:08:26.6377454+01:00||;True|2024-02-18T17:07:45.2050537+01:00||;True|2024-02-18T17:05:12.7495146+01:00||;True|2024-02-18T17:02:32.4549017+01:00||;True|2024-02-18T16:48:25.3074382+01:00||;True|2023-10-19T00:00:28.0962969+02:00||;True|2022-11-13T02:33:03.7406004+01:00||;True|2022-11-13T02:19:07.9073988+01:00||;True|2022-11-13T02:18:35.3043045+01:00||;True|2022-11-12T20:05:07.6366825+01:00||;False|2022-11-12T20:04:52.3576134+01:00||;True|2022-11-12T19:36:12.8480978+01:00||;</History>
<LastFailureDetails />
</PropertyGroup>
</Project>

0 comments on commit 2c13b22

Please sign in to comment.