using System.Diagnostics;
using System.ServiceProcess;
ServiceController sc = new ServiceController("iisadmin");
if (sc.Status == ServiceControllerStatus.Running)
{
sc.Stop();//停止
}
// ServiceController sc = new ServiceController("iisadmin");
// sc.Start();//启动
Process.Start("iisreset");//重启
主要是Diagnostics、ServiceProcess量个命名空间