Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

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

Posted on 2008-06-16
3
Medium Priority
?
323 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 2000 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

Get your Conversational Ransomware Defense e‑book

This e-book gives you an insight into the ransomware threat and reviews the fundamentals of top-notch ransomware preparedness and recovery. To help you protect yourself and your organization. The initial infection may be inevitable, so the best protection is to be fully prepared.

Question has a verified solution.

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

If you are a web developer, you would be aware of the <iframe> tag in HTML. The <iframe> stands for inline frame and is used to embed another document within the current HTML document. The embedded document could be even another website.
As tax season makes its return, so does the increase in cyber crime and tax refund phishing that comes with it
How to fix incompatible JVM issue while installing Eclipse While installing Eclipse in windows, got one error like above and unable to proceed with the installation. This video describes how to successfully install Eclipse. How to solve incompa…
In a question here at Experts Exchange (https://www.experts-exchange.com/questions/29062564/Adobe-acrobat-reader-DC.html), a member asked how to create a signature in Adobe Acrobat Reader DC (the free Reader product, not the paid, full Acrobat produ…
Suggested Courses

963 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