Need to find Default Web Site's Home Directory

2019-07-19 21:12发布

问题:

My InstallShield installer needs to install a file in the IIS Default Web Site's Home Directory, and set it to the default web page.

Unfortunately, in our environments, I can't assume that the home directory is C:\Inetpub\wwwroot, but I need to find out what it is.

Any idea on how I can do this with a script? We need to support XP, 2003 and 2008.

回答1:

Found it - it's dead simple:

Dim objIIsWebService
Set objIIsWebService = GetObject("IIS://localhost/W3SVC/1/ROOT")
wscript.echo objIIsWebService.Path

I knew there had to be an easy way!



回答2:

You can use a script to enumerate the IIS Web Sites and query them for information.

Something like

SET objWebService = GetObject( "IIS://" & strServer & "/W3SVC" )
FOR EACH objWebServer IN objWebService
  objWebService.SomeProperty
  ...

But I think this belongs on Server Fault.



标签: iis-7 iis-6