Small is New Big in C#

Coding

How to get windows service start property

leave a comment »

using System;
using System.Collections.Generic;
using System.Text;
using System.Management;

namespace ConsoleApplication1
{
    class Program
    {

        static void Main(string[] args)
        {
            ManagementObjectSearcher s =
                new ManagementObjectSearcher("root\\CIMV2","SELECT * FROM Win32_Service",
                new EnumerationOptions(
                null, System.TimeSpan.MaxValue,
                1, true, false, true,
                true, false, true, true));
            foreach (ManagementObject service in s.Get())
            {
                Console.WriteLine(service.Path.ToString());
               Console.WriteLine( service.GetPropertyValue("StartMode").ToString());
            }
            Console.ReadLine();
        }
    }
}

Advertisements

Written by nauhil

July 9, 2010 at 8:52 am

Posted in Levels Of Details

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: