Solved

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

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

Ransomware: The New Cyber Threat & How to Stop It

This infographic explains ransomware, type of malware that blocks access to your files or your systems and holds them hostage until a ransom is paid. It also examines the different types of ransomware and explains what you can do to thwart this sinister online threat.  

Question has a verified solution.

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

When it comes to showing a 404 error page to your visitors, you do not want that generic page to show, and you especially do not want your hosting provider’s ad error page to show either. In this article, I will show you how to enable the custom 40…
A phishing scam that claims a recipient’s credit card details have been “suspended” is the latest trend in spoof emails.
Nobody understands Phishing better than an anti-spam company. That’s why we are providing Phishing Awareness Training to our customers. According to a report by Verizon, only 3% of targeted users report malicious emails to management. With compan…

830 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