You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
29 lines
656 B
C#
29 lines
656 B
C#
using System;
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using System.ServiceProcess;
|
|
using System.Text;
|
|
using System.Threading.Tasks;
|
|
|
|
namespace ServiceDeamon
|
|
{
|
|
public class CheckServiceHelper
|
|
{
|
|
private static ServiceController servCtl;
|
|
|
|
|
|
public static void CheckStatus(string servName)
|
|
{
|
|
if (servCtl == null || servCtl.ServiceName != servName)
|
|
{
|
|
servCtl = new ServiceController(servName);
|
|
}
|
|
|
|
if (servCtl != null && servCtl.Status == ServiceControllerStatus.Stopped)
|
|
{
|
|
servCtl.Start();
|
|
}
|
|
}
|
|
}
|
|
}
|