From 13d9a92abb2f9c2adce0f2d0bc67beb9ab5aa5a5 Mon Sep 17 00:00:00 2001 From: Jordan Dominion Date: Sun, 25 Jun 2023 19:28:11 -0400 Subject: [PATCH] Run configure app as winforms to be non-intrusive --- .../Program.cs | 22 +++++-------------- ...ation.Server.Host.Service.Configure.csproj | 4 +++- 2 files changed, 9 insertions(+), 17 deletions(-) diff --git a/build/package/winget/Tgstation.Server.Host.Service.Configure/Program.cs b/build/package/winget/Tgstation.Server.Host.Service.Configure/Program.cs index 9d5c5bb53b..bf8710aa15 100644 --- a/build/package/winget/Tgstation.Server.Host.Service.Configure/Program.cs +++ b/build/package/winget/Tgstation.Server.Host.Service.Configure/Program.cs @@ -5,6 +5,7 @@ using System.Linq; using System.Reflection; using System.Security.AccessControl; using System.Threading; +using System.Windows.Forms; using var process = new Process(); @@ -44,22 +45,18 @@ var uninstall = args var shortcut = uiLevel == 42069; -bool startService; +bool restartService; if (shortcut) { - Console.WriteLine(); - Console.WriteLine("This program will configure tgstation-server. Would you like to restart the service after doing so?"); - Console.Write("A restart is required to apply changes. It will not kill your DreamDaemon instances provided you are running a version >=5.13.0 (Y/n): "); - var keyInfo = Console.ReadKey(); - startService = keyInfo.Key == ConsoleKey.Enter || keyInfo.Key == ConsoleKey.Y; - Console.WriteLine(); + var result = MessageBox.Show($"This program will configure tgstation-server. Would you like to restart the service after doing so?{Environment.NewLine}{Environment.NewLine}A restart is required to apply changes. It will not kill your DreamDaemon instances provided you are running a version >=5.13.0 (Always true if you've never downgraded)", "Restart TGS After Configuring?", MessageBoxButtons.YesNo); + restartService = result == DialogResult.Yes; } else - startService = interactive; + restartService = interactive; process.StartInfo.Arguments = uninstall ? "-u" - : $"-i -f -x{(startService ? " -r" : String.Empty)}{((interactive || shortcut) ? " -c" : String.Empty)}{(silent ? " -s" : String.Empty)}"; + : $"-i -f -x{(restartService ? " -r" : String.Empty)}{((interactive || shortcut) ? " -c" : String.Empty)}{(silent ? " -s" : String.Empty)}"; process.Start(); @@ -91,12 +88,5 @@ if ((shortcut || (interactive && !uninstall)) && process.ExitCode == 0) fileInfo.SetAccessControl(fs); } -if (shortcut) -{ - Console.WriteLine("Press any key to exit this program..."); - Console.ReadKey(); - Console.WriteLine(); -} - // returning non-zero can make the installation uninstallable, no thanks return uninstall ? 0 : process.ExitCode; diff --git a/build/package/winget/Tgstation.Server.Host.Service.Configure/Tgstation.Server.Host.Service.Configure.csproj b/build/package/winget/Tgstation.Server.Host.Service.Configure/Tgstation.Server.Host.Service.Configure.csproj index e0c822ad1b..af4c4af760 100644 --- a/build/package/winget/Tgstation.Server.Host.Service.Configure/Tgstation.Server.Host.Service.Configure.csproj +++ b/build/package/winget/Tgstation.Server.Host.Service.Configure/Tgstation.Server.Host.Service.Configure.csproj @@ -1,8 +1,9 @@ - Exe + WinExe net6.0-windows + true enable ../../../uac_elevation_manifest.xml ../../../tgs.ico @@ -11,4 +12,5 @@ +