
dave-20081.5524910892463362E12 asked a question.
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?
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
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
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.
That worked perfectly ;)
-Dánjal