NFe.Components.ServiceProcess.IsServiceInstalled C# (CSharp) Method

IsServiceInstalled() public static method

public static IsServiceInstalled ( string serviceName ) : bool
serviceName string
return bool
        public static bool IsServiceInstalled(string serviceName)
        {
            // get list of Windows services
            ServiceController[] services = ServiceController.GetServices();

            // try to find service name
            foreach (ServiceController service in services)
            {
                if (service.ServiceName == serviceName)
                    return true;

                //if (service.ServiceName.ToLower().StartsWith("u"))
                //MessageBox.Show(service.ServiceName);
            }
            return false;
        }