Pra*_*ana 10
使用托管代码检测IIS是否已安装且ASP/ASP.NET是否已注册
IIS运行或不检查下面的代码
只需在项目中添加"System.ServiceProcess"的参考.
ServiceController sc = new ServiceController("World Wide Web Publishing Service");
if ((sc.Status.Equals(ServiceControllerStatus.Stopped) || sc.Status.Equals(ServiceControllerStatus.StopPending))) {
Console.WriteLine("Starting the service...");
sc.Start();
}
else {
Console.WriteLine("Stopping the service...");
sc.Stop();
}
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
7637 次 |
| 最近记录: |