C#启动Windows IIS服务的实例
代码说明:
C#启动指定的Windows信使服务,本例中是启动IIS服务,在Windows XP下可完美运行,在Windows7下不行好像,本程序演示如何在C#的程序中启动一个指定的Windows内置服务的方法。具体的实现代码: ServiceController service = new ServiceController();//创建服务控制对象 service.ServiceName = "Messenger";//启动Windows信史服务 //判断当前服务状态 if (service.Status == ServiceControllerStatus.Stopped) { try { service.Start();// 启动服务 service.WaitForStatus(ServiceControllerStatus.Running); } catch (InvalidOperationException) { MessageBox.Show("不能启动该服务!"); } }
下载说明:请别用迅雷下载,失败请重下,重下不扣分!


