/// <summary> /// The main entry point for the application. /// </summary> static void Main() { if (Environment.CommandLine.Contains("-service")) { if (ServiceCheck(true) == false) { ServiceController controller = new ServiceController(applicationName); controller.Start(); return; } ServiceBase[] services = new ServiceBase[] { new ServiceWrapper() }; ServiceBase.Run(services); } else if (Environment.CommandLine.Contains("-removeservice")) { if (ServiceCheck(false)) { ServiceController controller = new ServiceController(applicationName); if (controller.Status == ServiceControllerStatus.Running) controller.Stop(); ServiceInstaller.UnInstallService(applicationName); } } else { ConsoleApplication application = new ConsoleApplication(applicationPath, true); } }
protected override void OnStart(string[] args) { string applicationPath = Path.GetDirectoryName(Assembly.GetEntryAssembly().Location); application = new ConsoleApplication(applicationPath, false); }