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?
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
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
精彩评论