Mr AH
Mr AH

Reputation: 1120

How do I get the current Application Name (in terms of IIS) in a classic asp Web application

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?

Upvotes: 1

Views: 1337

Answers (2)

Thomas Kjørnes
Thomas Kjørnes

Reputation: 1927

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

Upvotes: 3

My Other Me
My Other Me

Reputation: 5117

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

Upvotes: 0

Related Questions