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