Monday, February 25, 2013

How to Start/Stop Service using Coding?



ServiceController controller = ServiceController.GetServices().Where(s => s.ServiceName == "ServiceName").FirstOrDefault();
if (controller == null)
{
      MessageBox.Show("Service is missing.");
      return;
}
if (controller.Status == ServiceControllerStatus.Stopped)
{
     controller.Start();
}
else if (controller.Status == ServiceControllerStatus.Running)
{
     controller.Stop();
 }

Thursday, January 24, 2013

cannot open window service on computer '.' in window application

Go  c://Program Files/ApplicationFolder/.exe Right click on .exe and go to Properties then go Compability Tab and check true to Run this Program as an administrator Level.