.NET - What is the best library for inspecting and controling Windows Services?
-
27-09-2019 - |
Question
I need to monitor and control a set of Windows Services that are running either on a local machine or remotely. I've heard of WMI and ADSI and the first one seems to do what I want. Before going deep into it, I just want to check if I'm going in the right direction?
Thank you
EDIT Additional information: I also need to inspect SQL jobs and IIS instances so I think WMI is what I need.
Solution
You might want to look at the ServiceController
class.
http://msdn.microsoft.com/en-us/library/system.serviceprocess.servicecontroller.aspx
OTHER TIPS
This might help for WMI monitoring SQL job events:
You could also check Win32_NTLogEvent class:
wmic /namespace:\\root\cimv2 path win32_ntlogevent where SourceName='%SQL%' get /all /format:csv >"%userprofile%\desktop\wmic_win32_ntlogevent.csv"
However I don't think this will list specific SQL jobs. That type of action should be done in SQL itself. ADSI is Active Directory Services Interface, I don't think this what you'll need this however that will depend.