I recently ran into an executable for a web application that threw an error message/exception in a Custom Action.
As it turns out, the error message was thrown because the Custom Action was dependent on an installation of IIS being present.
Fortunately, detecting IIS is rather simple using a Windows Installer package such as InstallShield.
If you use the Internet Information Services deployment capabilities under the Server Configuration section of InstallShield, IIS detection will automatically occur for you.
However, one downside of using the InstallShield IIS capabilities is that it severely restricts you to the supported versions of IIS that ship with the version of InstallShield that you are using. In addition, the ability to select available Web Sites and other configuration in IIS are also restricted.
Therefore, if you want this additional flexibility, it is better to perform your own IIS detection. This can be done through using System Search.
You will want to create a System Search for a Registry Entry with the following path: HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\InetStp\InstallPath
Once you have created the System Search, you will want to store the value in a Property and use it as an Install Condition.
Then, when you run the installation, if IIS is not installed, then you will receive an error message indicating that you need to install IIS before proceeding with the installation.
This technique should work for most versions of Windows Server. I have tested this with versions of Windows Server from Windows Server 2003 all the way through Windows Server 2012 R2 and it has worked in all of these instances!