O'Reilly logo

Microsoft® Visual Basic® .NET Programmer's Cookbook by Matthew MacDonald

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Retrieve Information About Installed Windows Services

Problem

You want to retrieve information about all the services on your computer.

Solution

Use the shared ServiceController.GetServices method.

Discussion

.NET allows you to interact with any installed Windows service using the ServiceContoller class. The ServiceController class includes information such as

  • The service name and description.

  • The status of the service (running, stopped, paused, and so on).

  • Whether or not the service supports pause and continue and shutdown.

  • What other services this service depends on.

You can create a ServiceController object bound to a specific service by specifying the service name in the constructor, as shown here:

Dim TestService As New ServiceController("TestService") ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required