public HellionExtendedServer(string[] args)
        {
            Log.Warn("Initializing HellionExtendedServer v" + HellionExtendedServer.VersionString);


            m_instance = this;
        }
示例#2
0
        private static void Main(string[] args)
        {
            var hes = new HellionExtendedServer(args);

            _handler += new EventHandler(Handler);
            SetConsoleCtrlHandler(_handler, true);

            if (Environment.UserInteractive)
            {
                Console.Title = "HellionExtendedServer v" + HellionExtendedServer.VersionString;

                if (args.Length > 0)
                {
                    try
                    {
                        switch (args[0])
                        {
                        case "-install":
                        {
                            if (!IsAdministrator())
                            {
                                Log.Error("Hellion Extended Server: You must run HES as an Administrator to install it as a service!");
                                break;
                            }
                            Log.Warn("Installing Hellion Extended Server as a service.");
                            ManagedInstallerClass.InstallHelper(new string[] { System.Reflection.Assembly.GetExecutingAssembly().Location });
                            Log.Warn("Hellion Extended Server: Installed as a service.");
                            break;
                        }

                        case "-uninstall":
                        {
                            if (!IsAdministrator())
                            {
                                Log.Error("Hellion Extended Server: You must run HES as an Administrator to uninstall the service!");
                                break;
                            }
                            Log.Warn("Uninstalling Hellion Extended Server Service.");
                            ManagedInstallerClass.InstallHelper(new string[] { "/u", System.Reflection.Assembly.GetExecutingAssembly().Location });
                            Log.Warn("Hellion Extended Server: Service has been Uninstalled.");
                            break;
                        }
                        }
                    }
                    catch (Exception ex)
                    {
                        Log.Error(ex, "Hellion Extended Server: Error Installing or Uninstalling Service");
                    }

                    Log.Info("Press any key to Close.");
                    Console.ReadKey();
                    return;
                }

                hes.Run(args);
            }
            else
            {
                ServiceBase.Run(new ServiceBase[] { new HESService(args) });
            }
        }