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();
}