In a Windows form Application how to know iis is installed in local machine using c# programmatically
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;
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));
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With