get list of services on a pc

  • Thread starter Yankee Imperialist Dog
  • Start date
Y

Yankee Imperialist Dog

is there a way to get a list of all services that exist on a pc/server?

knowing the name it's easy to get a reference
ServiceController sc = new ServiceController("A Service Installed Here");
but i'd like to get a list of all services.

Thanks
 
Y

YankeeImperialistDog

Figured it out

using Microsoft.Win32;
----
----
--

RegistryKey rk = Registry.LocalMachine;
rk = rk.OpenSubKey(@"SYSTEM\CurrentControlSet\Services");
foreach (string keyName in rk.GetSubKeyNames())
{
Console.WriteLine(keyName);
}

thanks
KES
 
M

Michael C

YankeeImperialistDog said:
Figured it out
rk = rk.OpenSubKey(@"SYSTEM\CurrentControlSet\Services");
foreach (string keyName in rk.GetSubKeyNames())

Surely there is a better way than that. What happens if they change the
location of this information in the registry or decide to add extra keys
that don't represent a service, or create services somewhere else in the
registry. I think dot net has built in support for this. If not, use
interop.

Michael
 
J

Jeroen Mostert

Yankee said:
is there a way to get a list of all services that exist on a pc/server?

knowing the name it's easy to get a reference
ServiceController sc = new ServiceController("A Service Installed Here");
but i'd like to get a list of all services.
ServiceController.GetServices().
 
Y

YankeeImperialistDog

this does answer the question above. And yes this is the better way.
Your help and commets are appreciated.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top