Solved

Changing web site's DefaultDoc using a script gives weird results (IIS 6)

Posted on 2008-06-16
3
316 Views
Last Modified: 2008-09-17
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

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

Open in new window

0
Comment
Question by:javilmer
3 Comments
 
LVL 37

Accepted Solution

by:
meverest earned 500 total points
ID: 21808624
Hi,

that script works just fine for me.  Make sure that you hit the 'refresh' function in the IIS admin interface before viewing the changes in the default doc property.

Cheers.
0

Featured Post

What Security Threats Are You Missing?

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

Join & Write a Comment

Suggested Solutions

Today I came across an interesting issue that had me pulling my hair out.  I was troubleshooting a new internal web site which uses integrated security instead of anonymous.  When browsing the site from my laptop, I was able to access it with no iss…
Prologue It is often required to host multiple websites on a single instance of IIS, mostly in development environments instead of on production servers. I am sure it is not much a preferred solution on production servers but this is at least a pos…
Internet Business Fax to Email Made Easy - With eFax Corporate (http://www.enterprise.efax.com), you'll receive a dedicated online fax number, which is used the same way as a typical analog fax number. You'll receive secure faxes in your email, fr…
Excel styles will make formatting consistent and let you apply and change formatting faster. In this tutorial, you'll learn how to use Excel's built-in styles, how to modify styles, and how to create your own. You'll also learn how to use your custo…

760 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

18 Experts available now in Live!

Get 1:1 Help Now