2012-03-22 12 views

答えて

7

Using Managed Code to Detect if IIS is Installed and ASP/ASP.NET is Registered

ちょうどあなたのプロジェクトに "System.ServiceProcess" の参照を追加し、コード

の下にチェックし実行しているかいないIIS。

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(); 
} 
+0

サービス名「W3SV」は、iis5.0、iis6.0などのすべてのiisに共通ですか? –

+0

@mahesh - 実行して確認する必要があるかどうかわからない。 –

+0

'World Wide Web publishing'を使用すると、鉱山がクラッシュする。それに「サービス」を追加すると、それが機能するようになりました。また、 'W3SVC'で動作します –

関連する問題