Avatar of Sam T
Sam T
 asked on

Start, Stop and know the status of windows services

I am creating windows services using C# , and configurator for the service using windows form app in C#. So, I want to include start, stop and know the state of the service( Running/Stopped) functionality on my configurator, how would I do this using C# ? So if I click start button it is going to start the service and if I click the Stop button it would stop the service, and text field should display the status of the service (running, or stopped).

 All I want to make my configurator user friendly, so that user don't have to go to Task Manger and manually stop or start the service. Not only for the service I created, but this would allow me to write any service name on the text field, and should give me service status, and if it is already running, and  I click stop button it should stop, if it is stopped, and I click start button it should run.
C#Windows OSGolang

Avatar of undefined
Last Comment
Sam T

8/22/2022 - Mon
ASKER CERTIFIED SOLUTION
it_saige

THIS SOLUTION ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
Start Free Trial
GET A PERSONALIZED SOLUTION
Ask your own question & get feedback from real experts
Find out why thousands trust the EE community with their toughest problems.
Sam T

ASKER
I appreciate the solution @ it_Saige, I am gonna test the solution you provided, if it works the way I want, I will mark it as "this is my solution". Thank you again.
I started with Experts Exchange in 2004 and it's been a mainstay of my professional computing life since. It helped me launch a career as a programmer / Oracle data analyst
William Peck