views:

69

answers:

2

I have a classic asp application which retrieves the current application name and sets an Application variable containing that name. This name is important (I wont go into why) and is essentially the friendly name in IIS.

The problem is, the implementation used to get this name is flawed, it a) assumes the home directory contains the string wwwroot, and b) assumes the folder name is the same as the application name. I can no longer guarantee these conditions.

I would have thought the application name is know at run-time but I can't seem to find it in either Session or Application variables (at application start up entry point in global.asa). Any ideas?

A: 

If by friendly name you are referring to the IIS description, you might get some mileage out of the findweb.vbs file in the AdminScripts Folder of IIS (normally c:\Inetpub\AdminScripts) Some of the other scripts in that folder might be able to get you further too.

Try this aswell. It shows how to enumerate the IIS Websites through ADIS

My Other Me
+3  A: 

You may want to try something like this:

Dim obj
Dim inst

inst = Request.ServerVariables("INSTANCE_ID")

Set obj = GetObject("IIS://localhost/W3SVC/" + inst)

Response.Write obj.ServerComment
thomask
This might require special permissions to the IIS user account used with your app.
thomask
Thanks, this sort of works but of course only in session start and not application start. The problem is on IIS6 I get "Default Web" site, as this is actually the site name which holds the virtual directory.I have now noticed areas of this application where we would run into issues as in some areas code uses the app name to get the folder path! so the app is fundamentally flawed
Mr AH