cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
honolua
Level 7

Detect IIS

I'm trying to find a reliable way of detecting whether IIS7 is installed on a Windows Server 2008 machine. The most common method I've seen is to check for \\HKLM\SOFTWARE\Microsoft\InetStp. However, this method is flawed. This registry key appears to be created when the "Web Server (IIS)" role is installed but if the role is removed this registry key remains which results in a false positive. Does anyone have a better detection mechanism that's triggered off the presence/absence of DLL or some combination of conditions?
Labels (1)
0 Kudos
(8) Replies
Lurean
Level 8

What type of install project are you using?

You should be able to use the IIS_VERSION property within a Basic MSI or Installscript MSI project to determine the version of IIS installed on the target machine.

If there is no IIS installed, this property is undefined and will always evaluate to false.

James
0 Kudos
honolua
Level 7

IIS_VERSION appears to only get set if you use the built-in IIS functionality. For a variety of reasons we cannot do this. The primary reason is that our software gives the client the ability to set the vroot name to whatever they want at install time. The built-in functions appear to require that we hard-code the vroot name. There are also several features we need to configure which simply cannot be done within the current IIS features within IS2009. Is there another detection that is reliable to simply determine if IIS7 in installed or not?
0 Kudos
Lurean
Level 8

you could check the value of the \\HKLM\SOFTWARE\Microsoft\InetStp\InstallPath registry key and then use that path to determine which version if any is installed. The directory should not be present if it was uninstalled at some point even if the key is still there.
0 Kudos
honolua
Level 7

That's the current method I'm attempting to get to work. Unfortunately I end up here ... http://community.acresso.com/showthread.php?t=187789
0 Kudos
honolua
Level 7

After solving the non-expanded string problem I looked at what DLL files are installed and what files get uninstalled. We will be pulling the path to IIS from the registry and checking for "iiscore.dll" to verify whether IIS is really installed or not. We're also looking at the MajorVersion registry entry to verify that it is IIS7 that's installed.
0 Kudos
danjal
Level 5

Hi Honolua,

How do you read the MajorVersion from registry and check if it is version 6 or higher?

Here is what I am trying to do, but it fails:

RegDBSetDefaultRoot(HKEY_LOCAL_MACHINE);
RegDBGetKeyValueEx ("SYSTEM\\CurrentControlSet\\Services\\W3SVC\\Parameters","MajorVersion",nvType,szReturn,nReturn);
StrReplace(szReturn,".","",0);
StrToNum(nReturn,szReturn);
if (szReturn < "6") then
MessageBox("The Internet Information Server must be version 6.0 or higher", SEVERE);
abort;
endif;

-danjal
0 Kudos
honolua
Level 7

@danjal

We're doing almost the same thing but on a different registry key in HKLM:

szKey = "SOFTWARE\\Microsoft\\InetStp";
szName = "MajorVersion";
nSize = 10;
nResult = RegDBGetKeyValueEx( szKey, szName, nType, szValue, nSize );
if ( StrCompare( szValue, "7" ) < 0 ) then
// wrong version of IIS is installed
return( FALSE );
endif;


If all you need is the version this should work (for IIS 7, anyway). If you need to know if IIS is currently installed you'll want to look at the same key to grab "InstallPath", expand it as necessary, then look for a DLL file such as "iiscore.dll" (again, in IIS 7) in the expanded directory. We thought our detection was sufficient with looking at the registry until I uninstalled IIS to validate our check and found the check thought IIS was installed after I had just uninstalled it.
0 Kudos
danjal
Level 5

Thank you Honolua!!!

That worked perfectly 😉


-Dánjal
0 Kudos