diff --git a/src/Tgstation.Server.Host.Service/GlobalSuppressions.cs b/src/Tgstation.Server.Host.Service/GlobalSuppressions.cs
index 2dac9c7cde..44ed7e1b55 100644
Binary files a/src/Tgstation.Server.Host.Service/GlobalSuppressions.cs and b/src/Tgstation.Server.Host.Service/GlobalSuppressions.cs differ
diff --git a/src/Tgstation.Server.Host.Service/Program.cs b/src/Tgstation.Server.Host.Service/Program.cs
index 96932140c2..5944978b4d 100644
--- a/src/Tgstation.Server.Host.Service/Program.cs
+++ b/src/Tgstation.Server.Host.Service/Program.cs
@@ -10,6 +10,7 @@ using System.Linq;
using System.Reflection;
using System.Security.Principal;
using System.ServiceProcess;
+using System.Windows.Forms;
using Tgstation.Server.Host.Watchdog;
namespace Tgstation.Server.Host.Service
@@ -30,7 +31,7 @@ namespace Tgstation.Server.Host.Service
/// The --install or -i option
///
[Option(ShortName = "i")]
- public bool Install { get; }
+ public bool Install { get; set; }
///
/// Check if the running user is a system administrator
@@ -48,23 +49,32 @@ namespace Tgstation.Server.Host.Service
///
public void OnExecute()
{
- if ((Install || Uninstall) && !IsAdministrator())
+ if (Environment.UserInteractive)
{
- //try to restart as admin
- var argList = Environment.GetCommandLineArgs().ToList();
- //its windows, first arg is .exe name guaranteed
- var exe = argList.First();
- argList.RemoveAt(0);
- var startInfo = new ProcessStartInfo
+ if (!IsAdministrator())
{
- UseShellExecute = true,
- Verb = "runas",
- Arguments = String.Join(" ", argList),
- FileName = exe,
- WorkingDirectory = Environment.CurrentDirectory,
- };
- using (Process.Start(startInfo))
- return;
+ if (!(Install || Uninstall))
+ {
+ var result = MessageBox.Show("You are running the TGS windows service executable directly. It should only be run by the service control manager. Would you like to install the service in this location?", "TGS Service", MessageBoxButtons.YesNo);
+ if (result == DialogResult.No)
+ return;
+ Install = true;
+ }
+
+ //try to restart as admin
+ //its windows, first arg is .exe name guaranteed
+ var exe = Environment.GetCommandLineArgs().First();
+ var startInfo = new ProcessStartInfo
+ {
+ UseShellExecute = true,
+ Verb = "runas",
+ Arguments = Install ? "-i" : "-u",
+ FileName = exe,
+ WorkingDirectory = Environment.CurrentDirectory,
+ };
+ using (Process.Start(startInfo))
+ return;
+ }
}
if (Install)
@@ -105,6 +115,7 @@ namespace Tgstation.Server.Host.Service
///
/// Entrypoint for the application
///
+ [STAThread]
static int Main(string[] args) => CommandLineApplication.Execute(args);
}
}
diff --git a/src/Tgstation.Server.Host.Service/Tgstation.Server.Host.Service.csproj b/src/Tgstation.Server.Host.Service/Tgstation.Server.Host.Service.csproj
index 54ee9a72db..77dd44b935 100644
--- a/src/Tgstation.Server.Host.Service/Tgstation.Server.Host.Service.csproj
+++ b/src/Tgstation.Server.Host.Service/Tgstation.Server.Host.Service.csproj
@@ -82,6 +82,7 @@
+