代码
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.ServiceProcess;
namespace ConsoleApplication1
{
class Program
{
static void Main(string[] args)
{
ServiceIsExisted(
"MSSQLSERVER");
}

private static bool ServiceIsExisted(string serviceName)
{
ServiceController[] services
= ServiceController.GetServices();
foreach (ServiceController s in services)
{
if (s.ServiceName == serviceName && s.Status == ServiceControllerStatus.Stopped)
{
s.Start();
return true;
}
}
return false;
}
}
}

 

相关文章:

  • 2021-10-24
  • 2022-12-23
  • 2021-12-25
  • 2021-06-07
  • 2022-12-23
  • 2022-12-23
  • 2021-09-12
  • 2022-12-23
猜你喜欢
  • 2022-12-23
  • 2021-12-27
  • 2021-11-22
  • 2022-12-23
  • 2021-11-01
相关资源
相似解决方案