Solved

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

Posted on 2008-06-16
3
320 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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

Enterprise Mobility and BYOD For Dummies

Like “For Dummies” books, you can read this in whatever order you choose and learn about mobility and BYOD; and how to put a competitive mobile infrastructure in place. Developed for SMBs and large enterprises alike, you will find helpful use cases, planning, and implementation.

Question has a verified solution.

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

Suggested Solutions

What is an ISAPI filter?   •      It's an assembly (.dll file) that can add or change the way IIS works.   •      They can be enabled globally for your web server or on a site-by-site basis.   When the IIS server receives a request, enabling the ISAPI fi…
If you don't have the right permissions set for your WordPress location in IIS, you won't be able to perform automatic updates. Here's how to fix the problem.
This video shows how to use Hyena, from SystemTools Software, to update 100 user accounts from an external text file. View in 1080p for best video quality.

752 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