检查IIS安装并运行 [英] Check IIS is installed and running
本文介绍了检查IIS安装并运行的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
在我们的申请中,我们要确定IIS是否被安装在一台机器。如果安装了,那么我们就需要确定它是否正在运行。
In our application we want to identify whether iis is installed in a machine. If installed, then we need identify whether it is running.
有没有什么办法让更多细节。
Is there any way to get this details.
推荐答案
的使用管理code以检测是否安装IIS和ASP / ASP.NET被注册
IIS运行或不检查以下code
只是为了System.ServiceProcess的引用添加到您的项目。
Just add a Reference for "System.ServiceProcess" to your Project.
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();
}
这篇关于检查IIS安装并运行的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文