Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
01/13/15 13:33:12 (9 years ago)
Author:
ascheibe
Message:

#2244 merged r11364,r11365,r11366,r11599,r11652 into stable

Location:
stable
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • stable

  • stable/HeuristicLab.Clients.Hive.Slave.WindowsService/3.3/Program.cs

    r11170 r11749  
    2020#endregion
    2121
     22using System;
     23using System.Configuration.Install;
     24using System.Reflection;
    2225using System.ServiceProcess;
    2326
    2427namespace HeuristicLab.Clients.Hive.SlaveCore.WindowsService {
    2528  static class Program {
    26     /// <summary>
    27     /// The main entry point for the application.
    28     /// </summary>
    29     static void Main() {
    30       ServiceBase[] ServicesToRun;
    31       ServicesToRun = new ServiceBase[] 
    32       {
    33         new SlaveWindowsService()
    34       };
    35       ServiceBase.Run(ServicesToRun);
     29    private static void Main(string[] args) {
     30      // Install as service, see http://stackoverflow.com/a/12703878
     31      if (Environment.UserInteractive) {
     32        try {
     33          string parameter = string.Concat(args);
     34          switch (parameter) {
     35            case "--install":
     36              ManagedInstallerClass.InstallHelper(new[] { Assembly.GetExecutingAssembly().Location });
     37              break;
     38            case "--uninstall":
     39              ManagedInstallerClass.InstallHelper(new[] { "/u", Assembly.GetExecutingAssembly().Location });
     40              break;
     41          }
     42        }
     43        catch (Exception ex) {
     44          Console.WriteLine("Error on (un)install of Hive Slave service: " + Environment.NewLine + ex);
     45        }
     46      } else {
     47        ServiceBase[] ServicesToRun;
     48        ServicesToRun = new ServiceBase[]
     49        {
     50          new SlaveWindowsService()
     51        };
     52        ServiceBase.Run(ServicesToRun);
     53      }
    3654    }
    3755  }
Note: See TracChangeset for help on using the changeset viewer.