javilmer
asked on
Changing web site's DefaultDoc using a script gives weird results (IIS 6)
Hi,
I am trying to change an IIS web site's default document with a script, and I'm getting weird results (see code).
I'm running the script once to change the DefaultDoc, I get no error message. Then I remove the following lines:
WebServer.DefaultDoc = "homepage.htm"
WebServer.SetInfo
... and run the script again: the result seems ok, it says "WebServer.DefaultDoc = homepage.htm". BUT, when I check in IIS management console, default documents list didn't change... Moreover, default documents displayed during first script execution were not the same as those seen in web site's properties dialog box.
I also checked WebServer.Name value, and it's the correct web site identifier.
Any idea?
Thanks in advance for the help,
Laurent
I am trying to change an IIS web site's default document with a script, and I'm getting weird results (see code).
I'm running the script once to change the DefaultDoc, I get no error message. Then I remove the following lines:
WebServer.DefaultDoc = "homepage.htm"
WebServer.SetInfo
... and run the script again: the result seems ok, it says "WebServer.DefaultDoc = homepage.htm". BUT, when I check in IIS management console, default documents list didn't change... Moreover, default documents displayed during first script execution were not the same as those seen in web site's properties dialog box.
I also checked WebServer.Name value, and it's the correct web site identifier.
Any idea?
Thanks in advance for the help,
Laurent
Set w3svc = GetObject("IIS://localhost/w3svc")
For Each WebServer in w3svc
'If the class of the current object is a webserver
If WebServer.Class = "IIsWebServer" Then
sSiteName = WebServer.ServerComment
if sSiteName = "web_site_to_be_modified.com" then
WScript.echo(sSiteName)
WScript.echo( "WebServer.Name = " & WebServer.Name )
WScript.echo( "WebServer.DefaultDoc = " & WebServer.DefaultDoc )
WebServer.DefaultDoc = "homepage.htm"
WebServer.SetInfo
End If
End If
Next
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.