Click here to Skip to main content
15,891,719 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi All,

This is regarding fetching the data from Services (Windows Consoles). I have some of the services in the machines where i have to login remotely and have to open and check the status of few particular services like EX: In our Task Manager window, we have a tab called SERVICES. In that tab, we'll have all the services running and beside columns will provied the status Running, Stopped or something.

Like that, I have to login to some remote machine and open the Services window (Console Window) and check for few services and update the status in Excel. I would like to automate this.

I'm very new to .Net. Can you anyone suggest me how to start with this?
Posted
Updated 27-Jan-16 23:10pm
v4
Comments
F-ES Sitecore 28-Jan-16 4:45am    
You'll need to give a bit more detail. What do you mean by "services"? Do you mean Windows Service? Also what exactly about them do you want to check?
Member 8010354 28-Jan-16 5:10am    
Hi, I have updated my question. Please let me know if anything i can change to be more specific. I will try.

1 solution

C#
// needs a reference to System.ServiceProcess.dll
System.ServiceProcess.ServiceController[] services = System.ServiceProcess.ServiceController.GetServices("target-machine-name-or-IP-here");

foreach (System.ServiceProcess.ServiceController service in services)
{
    var machine = service.MachineName;
    var displayName = service.DisplayName;
    var status = service.Status;
}


Obviously the account you run the code under needs the required access rights.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900