There are several tricks but I've not seen this one so I would like to mention this trick as well.
The idea is that IIS can be managed through ADSI interfaces right? You would use (in vbscript)
Sest myIIS = GetObject("IIS:") and now you have the namespace. But if IIS is not installed, it would return 'invalid syntax'. Not really a good error.
A cleaner method would be
Set myIIS = CreateObject("IIS")
This way, you use the progid that the IIS namespace, normally is fetched by a url moniker and GetObject().
so complete code:
Dim myIIS, isIISInstalled
On Error Resume Next
Set myIIS = CreateObject("IIS")
'ActiveX component cannot create object: 'IIS'
isIISInstalled = Err.Number <> &H800A01AD
On Error GoTo 0
You can apply the concept above to -any- language, including javascript, VB6, C# and VB.NET.