Finding IIS home directory with getObject

I would like to enumerate the web sites on a server and find the physical
directory for each. I can enumerate them with the following code:

set objW3 = getObject("IIS://localhost/W3SVC")
for each webSite in objW3
webSite.ServerComment 'Web site name
next

But I can't figure out what property to use to find the file path.
webSite.Path creates an error.

Can anyone point me in the right direction? And if this is not the proper
forum to ask the question, you could direct me to the proper forum.

Many thanks,

Steve
Steve Ricketts [ Fr, 01 Juni 2007 22:28 ] [ ID #1728027 ]

Re: Finding IIS home directory with getObject

From memory

..ServerComment is stored as an attribute of the website. However .Path is an
attribute of the "Root" node located underneath the website. So you may need
to get a handle to the root node first.

Cheers
Ken


"Steve Ricketts" <Velocedge [at] hotmail.com> wrote in message
news:%23GNE0tIpHHA.3368 [at] TK2MSFTNGP02.phx.gbl...
>I would like to enumerate the web sites on a server and find the physical
>directory for each. I can enumerate them with the following code:
>
> set objW3 = getObject("IIS://localhost/W3SVC")
> for each webSite in objW3
> webSite.ServerComment 'Web site name
> next
>
> But I can't figure out what property to use to find the file path.
> webSite.Path creates an error.
>
> Can anyone point me in the right direction? And if this is not the proper
> forum to ask the question, you could direct me to the proper forum.
>
> Many thanks,
>
> Steve
>
Ken Schaefer [ Sa, 02 Juni 2007 06:48 ] [ ID #1728605 ]

Re: Finding IIS home directory with getObject

I guess that's part of my problem. I know how to get the root node of one
web using something like:

set objWebsite = getObject("IIS://localhost/W3SVC/1/Root")
sDirectory = objWebsite.Path

But I don't know how to get the other sites. I thought incrementing the 1
would make sense but that didn't work. So, if I have the Website object.
how do I get it's root node from that object?

Thanks for the help, very much appreciated.

Steve


"Ken Schaefer" <kenREMOVE [at] THISadOpenStatic.com> wrote in message
news:uEumMFNpHHA.1240 [at] TK2MSFTNGP06.phx.gbl...
> From memory
>
> .ServerComment is stored as an attribute of the website. However .Path is
> an attribute of the "Root" node located underneath the website. So you may
> need to get a handle to the root node first.
>
> Cheers
> Ken
>
>
> "Steve Ricketts" <Velocedge [at] hotmail.com> wrote in message
> news:%23GNE0tIpHHA.3368 [at] TK2MSFTNGP02.phx.gbl...
>>I would like to enumerate the web sites on a server and find the physical
>>directory for each. I can enumerate them with the following code:
>>
>> set objW3 = getObject("IIS://localhost/W3SVC")
>> for each webSite in objW3
>> webSite.ServerComment 'Web site name
>> next
>>
>> But I can't figure out what property to use to find the file path.
>> webSite.Path creates an error.
>>
>> Can anyone point me in the right direction? And if this is not the
>> proper forum to ask the question, you could direct me to the proper
>> forum.
>>
>> Many thanks,
>>
>> Steve
>>
>
Steve Ricketts [ Sa, 02 Juni 2007 13:07 ] [ ID #1728612 ]

Answer: Finding IIS home directory with getObject

Ok, Ken's comments were enough for me to figure it out. Here's how you
enumerate the web sites and then retreive the site's path.

set objW3SVC = getObject("IIS://localhost/W3SVC")
for each IISwebSite in objW3SVC
debug.print IISwebSite.ServerComment 'Web site name
set objWeb = getObject(IISwebsite.adsPath & "/Root")
rootPath = objWeb.Path
next

Thanks for the pointers Ken!

Steve

"Steve Ricketts" <Velocedge [at] hotmail.com> wrote in message
news:%23GNE0tIpHHA.3368 [at] TK2MSFTNGP02.phx.gbl...
>I would like to enumerate the web sites on a server and find the physical
>directory for each. I can enumerate them with the following code:
>
> set objW3 = getObject("IIS://localhost/W3SVC")
> for each webSite in objW3
> webSite.ServerComment 'Web site name
> next
>
> But I can't figure out what property to use to find the file path.
> webSite.Path creates an error.
>
> Can anyone point me in the right direction? And if this is not the proper
> forum to ask the question, you could direct me to the proper forum.
>
> Many thanks,
>
> Steve
>
Steve Ricketts [ Sa, 02 Juni 2007 18:05 ] [ ID #1728614 ]
Webserver » microsoft.public.inetserver.iis » Finding IIS home directory with getObject

Vorheriges Thema: Please analyze this IIS State log
Nächstes Thema: Unbind SSL port to all IPs