From 6fc13cff70980a4dae1046efaddf7d2f1680a17a Mon Sep 17 00:00:00 2001 From: AffectedArc07 <25063394+AffectedArc07@users.noreply.github.com> Date: Sat, 8 Oct 2022 14:36:16 +0100 Subject: [PATCH] Try this --- src/Tgstation.Server.Host.Service/Program.cs | 34 +++++++++++--------- 1 file changed, 18 insertions(+), 16 deletions(-) diff --git a/src/Tgstation.Server.Host.Service/Program.cs b/src/Tgstation.Server.Host.Service/Program.cs index 62e4678903..40baaadd9d 100644 --- a/src/Tgstation.Server.Host.Service/Program.cs +++ b/src/Tgstation.Server.Host.Service/Program.cs @@ -120,27 +120,29 @@ namespace Tgstation.Server.Host.Service return; // oh no, it's retarded... // First check if the service already exists - foreach (ServiceController sc in ServiceController.GetServices()) + if (Environment.UserInteractive) { - if (sc.ServiceName == "tgstation-server" || sc.ServiceName == "tgstation-server-4") + foreach (ServiceController sc in ServiceController.GetServices()) { - DialogResult result = MessageBox.Show($"You already have another TGS service installed ({sc.ServiceName}). Would you like to uninstall it now? Pressing \"No\" will cancel this install.", "TGS Service", MessageBoxButtons.YesNo); - if (result != DialogResult.Yes) + if (sc.ServiceName == "tgstation-server" || sc.ServiceName == "tgstation-server-4") { - Environment.Exit(1); - return; // is this needed after exit? - } + DialogResult result = MessageBox.Show($"You already have another TGS service installed ({sc.ServiceName}). Would you like to uninstall it now? Pressing \"No\" will cancel this install.", "TGS Service", MessageBoxButtons.YesNo); + if (result != DialogResult.Yes) + { + return; // is this needed after exit? + } - // Stop it first to give it some cleanup time - if (sc.Status == ServiceControllerStatus.Running) - sc.Stop(); + // Stop it first to give it some cleanup time + if (sc.Status == ServiceControllerStatus.Running) + sc.Stop(); - // And remove it - using (ServiceInstaller si = new ServiceInstaller()) - { - si.Context = new InstallContext($"old-{sc.ServiceName}-uninstall.log", null); - si.ServiceName = ServerService.Name; - si.Uninstall(null); + // And remove it + using (ServiceInstaller si = new ServiceInstaller()) + { + si.Context = new InstallContext($"old-{sc.ServiceName}-uninstall.log", null); + si.ServiceName = ServerService.Name; + si.Uninstall(null); + } } } }