How to code for a stop and start of a windows service ?

namreg

New member
Joined
Jun 6, 2018
Messages
3
Programming Experience
Beginner
Hello,

I am new with C# and know just the basics.

I would like to create a command line executable where the program can stop and start a windows service through a windows domain account ?

Is that possible ?

We always get tickets to restart a windows service on a windows server. So, it will be nice if i create am executable or msi and give to the user, so she double clicks and stops and restart the service for her and acknowledging service status through a pop up.

Thoughts ? Thanks for your help,
 
The ServiceController class is what you're looking for. It's a component so that means that you can add an instance to a form in the designer and configure it there. You can, of course, create an instance in code if you prefer.
 
There's also a Project Type just for making a Windows Service program:

WindowsService.png
 
There's also a Project Type just for making a Windows Service program:

But that's for creating an actual service, where the request here is for a program that can stop and start a service.
 

Latest posts

Back
Top Bottom