Solved

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

Posted on 2008-06-16
3
317 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

U.S. Department of Agriculture and Acronis Access

With the new era of mobile computing, smartphones and tablets, wireless communications and cloud services, the USDA sought to take advantage of a mobilized workforce and the blurring lines between personal and corporate computing resources.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Running classic asp applications under Windows Server 2008 R2 (x64) and IIS 7 is not as easy as one may think. It took me a while to figure it out while getting error 8002801d a few times. After you install the OS you will need to install the fol…
Lync server 2013 or Skype for business Backup Service Error ID 4049 – After File Share Migration
Windows 10 is mostly good. However the one thing that annoys me is how many clicks you have to do to dial a VPN connection. You have to go to settings from the start menu, (2 clicks), Network and Internet (1 click), Click VPN (another click) then fi…
Sending a Secure fax is easy with eFax Corporate (http://www.enterprise.efax.com). First, just open a new email message. In the To field, type your recipient's fax number @efaxsend.com. You can even send a secure international fax — just include t…

895 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

13 Experts available now in Live!

Get 1:1 Help Now