Retrieve the list of running windows services using the Windows Management Interface (WMI)

By [)ia6l0 iii

Use the ManagementObjectSearcher to query the Win32 services and retrieve the list of services.

The code block below shows you how:

List<string> runningServices = new List<string>();

ManagementObjectSearcher moSearcher = new
ManagementObjectSearcher(""SELECT * FROM Win32_Service WHERE Started = TRUE"");

foreach (ManagementObject service in moSearcher.Get())
runningServices.Add(service[""Caption""]);

Related FAQs

Use the ManagementObjectSearcher to query the list of stopped services in Win32.
Download the WMI Code Generator from the Microsoft Download Center
Retrieve the list of running windows services using the Windows Management Interface (WMI)  (839 Views)