System.ServiceProcess.ServiceController 9.0.0-preview.1.24080.9
About
Provides the System.ServiceProcess.ServiceController API, which allows to connect to a Windows service, manipulate it, or get information about it. Not supported on other platforms.
Key Features
- Retrieve information from Windows services
- Connect to and manipulate Windows services (start, pause, stop or other operations)
How to Use
Retrieve Windows service information
using System.ServiceProcess;
// Loop through all installed Windows services and print the name, status and display name.
foreach (ServiceController serviceController in ServiceController.GetServices())
{
Console.WriteLine("Name: " + serviceController.ServiceName);
Console.WriteLine("Status: " + serviceController.Status.ToString());
Console.WriteLine("Display name: " + serviceController.DisplayName);
}
// Loop through all installed device driver services
foreach (ServiceController serviceController in ServiceController.GetDevices())
{
Console.WriteLine("Name: " + serviceController.ServiceName);
Console.WriteLine("Status: " + serviceController.Status.ToString());
Console.WriteLine("Display name: " + serviceController.DisplayName);
}
Manipulate a Windows service
using System.ServiceProcess;
ServiceController service = new("TestServiceName");
if (service.CanStop && service.Status != ServiceControllerStatus.Stopped && service.Status != ServiceControllerStatus.StopPending)
{
service.Stop();
}
Main Types
The main types provided by this library are:
System.ServiceProcess.ServiceControllerSystem.ServiceProcess.ServiceControllerStatusSystem.ServiceProcess.ServiceType
Additional Documentation
Feedback & Contributing
System.ServiceProcess.ServiceController is released as open source under the MIT license. Bug reports and contributions are welcome at the GitHub repository.
Showing the top 20 packages that depend on System.ServiceProcess.ServiceController.
| Packages | Downloads |
|---|---|
|
Microsoft.Web.Administration
This package contains the .NET Core version of the Microsoft Web Administration assembly.
|
8 |
|
DevExpress.EasyTest
The core functionality to run EasyTest functional tests for XAF apps.
|
6 |
|
DevExpress.Win.Design
.NET version of DevExpress controls with a preview version of design-time features. Requires Visual Studio v16.10 or newer.
|
6 |
|
DevExpress.Win.Dashboard.Design
.NET version of DevExpress Dashboard controls with a preview version of design-time features. Requires Visual Studio v16.10 or newer.
|
5 |
|
DevExpress.EasyTest
The core functionality to run EasyTest functional tests for XAF apps.
|
4 |
|
Microsoft.Web.Administration
This package contains the .NET Core version of the Microsoft Web Administration assembly.
|
4 |
|
DevExpress.Win.Design
.NET version of DevExpress controls with a preview version of design-time features. Requires Visual Studio v17.0 or newer.
|
2 |
|
DevExpress.Win.Dashboard.Design
.NET version of DevExpress Dashboard controls with a preview version of design-time features. Requires Visual Studio v17.0 or newer.
|
1 |
.NET Framework 4.6.2
- System.Diagnostics.EventLog (>= 9.0.0-preview.1.24080.9)
.NET 8.0
- System.Diagnostics.EventLog (>= 9.0.0-preview.1.24080.9)
.NET 9.0
- System.Diagnostics.EventLog (>= 9.0.0-preview.1.24080.9)
.NET Standard 2.0
- System.Diagnostics.EventLog (>= 9.0.0-preview.1.24080.9)