public void Run() { if (!WindowsServiceControlManager.IsInstalled(Description.GetServiceName())) { string message = string.Format("The {0} service is not installed.", Description.GetServiceName()); _log.Error(message); return; } if (!WindowsUserAccessControl.IsAdministrator) { if (!WindowsUserAccessControl.RerunAsAdministrator()) { _log.ErrorFormat("The {0} service can only be stopped by an administrator", Description.GetServiceName()); } return; } _log.DebugFormat("Attempting to stop '{0}'", Description.GetServiceName()); WindowsServiceControlManager.Stop(Description.GetServiceName()); _log.InfoFormat("The {0} service has been stopped.", Description.GetServiceName()); }
public void Run() { if (!WindowsServiceControlManager.IsInstalled(Description.GetServiceName())) { _log.ErrorFormat("The {0} service is not installed.", Description.GetServiceName()); return; } if (!WindowsUserAccessControl.IsAdministrator) { if (Sudo) { if (WindowsUserAccessControl.RerunAsAdministrator()) { return; } } _log.ErrorFormat("The {0} service can only be uninstalled as an administrator", Description.GetServiceName()); return; } _log.DebugFormat("Attempting to uninstall '{0}'", Description.GetServiceName()); WithInstaller(ti => ti.Uninstall(null)); }
public void Run() { if (WindowsServiceControlManager.IsInstalled(Description.GetServiceName())) { string message = string.Format("The {0} service is already installed.", Description.GetServiceName()); _log.Error(message); return; } if (!WindowsUserAccessControl.IsAdministrator) { if (Sudo) { if (WindowsUserAccessControl.RerunAsAdministrator()) { return; } } _log.ErrorFormat("The {0} service can only be installed as an administrator", Description.GetServiceName()); return; } _log.DebugFormat("Attempting to install '{0}'", Description.GetServiceName()); WithInstaller(ti => ti.Install(new Hashtable())); }