3

In a Windows form Application how to know iis is installed in local machine using c# programmatically

2 Answers 2

7

If the IIS is installed the registry key HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\InetStp should exist and it should contain an entry VersionString.

Source: here


private static bool IsIisInstalled() => Registry.GetValue(@"HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\InetStp", "VersionString", null) != null;
Sign up to request clarification or add additional context in comments.

Comments

6

With regards to checking the registry key, I have found that if you have IIS installed and you uninstall it, it leaves the key in the registry. Hence that is not a reliable way to test for the presence of IIS.

I opted for checking if the IIS Windows service exists using the following code:

IsIisInstalled = ServiceController.GetServices().Any(s => s.ServiceName.Equals("w3svc", StringComparison.InvariantCultureIgnoreCase));

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.