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") ...
Get Microsoft® Visual Basic® .NET Programmer's Cookbook now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.