December 17, 2009

Detecting if IIS and ASP are installed on the server

The best way to detect if IIS is installed is to look for the presence of the following registry key:

HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\InetStp

If this key exists, then IIS is installed. If it doesn't exist, IIS isn't installed. It really doesn't get any simpler than that. This key also provides some additional interesting information, such as the IIS version number. The version information is kept in the following registry values, both DWORDs:

MajorVersion

* 4: Shipped in NT Option Pack for Windows NT 4
* 5: Shipped in Windows 2000 Server and Windows XP Professional
* 6: Shipped in Windows Server 2003

MinorVersion

* 1: Indicates that IIS is installed on Windows XP Professional

Ok, now that we know IIS is installed, what about detecting if the web service components of IIS are installed? There are two ways to do this. One is to look for the following key:

HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Servic es\W3SVC

Again, if you don't have the web service components of IIS installed, this key shouldn't exist.

The other way is to look at the IIS subcompoments registry key:

HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\Curr entVersion\Setup\Oc Manager\Subcomponents

All of the values under this key are DWORDs, so if the value is 1 then it is installed. There are a lot of values listed here, but the interesting ones (at least for this discussion) are:

* iis_common - IIS Common Files
* iis_asp - Active Server pages (ASP) for IIS
* iis_www - World Wide Web (WWW) service

As you can see, this key can tell you if ASP is registered with IIS and if the web service components are installed.

Now that we know if ASP is registered, what about ASP.NET? Once again, we turn to the registry and look for the presence of the following keys:

* .NET 1.1 - HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\ASP.NET\1.1. 4322.0
* .NET 2.0 - HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\ASP.NET\2.0. 50727.0

No comments:

Post a Comment