Quantcast
Channel: .NET Framework Class Libraries forum
Viewing all articles
Browse latest Browse all 8156

ServiceController Class - Getting Startup Type

$
0
0

I have a console app that displays information about the services on a computer using the ServiceController class.  

The only thing I cannot pull is the Startup Type, e.g., Manual, Automatic.

using System;
using System.ServiceProcess;


namespace ConsoleApplication1
{
    class Program
    {
        static void Main(string[] args)
        {
            try
            {
                ServiceController[] sController = ServiceController.GetServices();
                Console.WriteLine("Running Services");
                Console.WriteLine("----------------");
                foreach (ServiceController sc in sController)
                {                                                        
                        Console.WriteLine(sc.ServiceName);
                        Console.WriteLine(sc.Status);
                        Console.WriteLine(sc.ServiceType);
                        Console.WriteLine(sc.DisplayName);
                        Console.WriteLine(sc.ServiceType);
                        Console.WriteLine("----------------");                                      
                }
                Console.ReadLine();
            }
            catch (Exception ex)
            {
                // handle ex
            }
        }
    }
}

Anyone know how to display the Startup Type of a service ?

Thanks


Viewing all articles
Browse latest Browse all 8156

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>