/// <summary> /// Stops Allsrv, either via AGClib, stopping the service, or by manually killing the process as appropriate /// </summary> public static void StopAllsrv() { // If Allsrv service isn't stopped, stop it! if (TagServiceController.AllsrvService != null) { if (TagServiceController.IsAllsrvServiceStarted()) { TagServiceController.StopAllsrvService(); } } else { // TODO: Should I kill allsrv.exe process? Kinda ugly... } }
/// <summary> /// Starts Allsrv in desktop or service mode as installed /// </summary> public static void StartAllsrv() { try { // If Allsrv is a stopped service, start it! if (TagServiceController.AllsrvService != null) { if (TagServiceController.IsAllsrvServiceStarted() == false) { TagServiceController.StartAllsrvService(); TagTrace.WriteLine(TraceLevel.Info, "Allsrv Service started."); } } else { // Start Allsrv in console mode string ServerEXEPath = null; // Get registry key RegistryKey ServerKey = Registry.LocalMachine.OpenSubKey(ALLEGIANCESERVERREGKEY); if (ServerKey != null) { ServerEXEPath = ServerKey.GetValue("EXE Path").ToString(); ServerKey.Close(); } else { throw new ApplicationException("Could not find Allsrv.exe"); } // start executable if (ServerEXEPath != null) { Process.Start(ServerEXEPath); TagTrace.WriteLine(TraceLevel.Info, "Allsrv started in console mode."); } } Thread.Sleep(1500); // Wait a second for Allsrv to start } catch (Exception e) { TagTrace.WriteLine(TraceLevel.Error, "Error starting Allsrv: {0}", e.Message); } }