tags:

views:

321

answers:

2

Hi,

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.

A: 

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.

bzlm
Hi,I actually tried this script, but it doesn't work on XP - there was an error in the WMI stuff. I was hoping there was a different way.
pduncan
+2  A: 

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!

pduncan
This will actually tell you the Home Directory of the IIS Web Site with the ID 1, which is usually the ID of the Default Web Site, if one exists. For a more robust solution, you should enumerate the Web Sites and check their names.
bzlm