Starting windows services from C# MVC 4

Sometime you need to start/stop windows services from your C# MVC application. Here i am sharing how you can do that: 1) To access windows service you need to add below namespace in your controller:

using System.ServiceProcess;

If you are getting error as "namespace name 'ServiceController' could not be found" while adding above namesapce you need to add using "Add Reference". For more details see my blog HERE 2) Add below code to your controller:

ServiceController service = new ServiceController("Test Windows Service");

It will start your services.

Your feedbacks are most welcome..