netmonitor/NetMonitorServer/Program.cs
2026-08-04 14:54:51 +02:00

45 lines
1.3 KiB
C#

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Configuration.Install;
using System.ServiceProcess;
using System.Threading;
using BlubbFish.Utils;
namespace NetMonitorServer {
[RunInstaller(true)]
public class InstallWindowsService : Installer {
public InstallWindowsService() {
this.Installers.Add(new ServiceInstaller {
ServiceName = "NetMonitorServer",
StartType = ServiceStartMode.Automatic,
Description = "Teil von NetMonitor der die Systemnahen Befele ausführt",
DisplayName = "Netmonitor Server"
});
this.Installers.Add(new ServiceProcessInstaller {
Account = ServiceAccount.LocalSystem
});
}
}
class Program {
static void Main(String[] args) => new Program(args);
public Program(String[] args) {
CmdArgs.Instance.SetArguments(new Dictionary<String, CmdArgs.VaildArguments> {
{ "-r", new CmdArgs.VaildArguments(CmdArgs.ArgLength.Single, false) }
}, args);
if(CmdArgs.Instance.HasArgumentType("-r")) {
ServiceBase.Run(new ServiceBase[] { new MainService() });
} else {
new MainService().StartServiceConsole(args);
while(true) {
Thread.Sleep(100);
}
}
}
}
}