using System.ServiceProcess;
ServiceController[] array = ServiceController.GetServices();
for (int i = 0; i < array.Length; i++)
{
ServiceController serviceController = array[i];
if (serviceController.ServiceName == "GuardService")
{
ServiceControllerStatus status = serviceController.Status;
if (status != ServiceControllerStatus.Stopped)
{
if (status == ServiceControllerStatus.Paused)
{
serviceController.Start();
}
}
else
{
serviceController.Start();
}
}
}