Windows IT Pro is the leading independent community for IT professionals deploying Microsoft Windows server and client applications and technologies.
  
  
  Advanced Search 


June 04, 2009

Fool iisweb.vbs Into Creating Websites Whose Home Directories Include UNC Paths

RSS
Subscribe to Windows IT Pro | See More Tips Articles Here | Reprints | Or get the Monthly Online Pass—only $5.95 a month!

Download the Code Here

The iisweb.vbs script that comes with IIS 6.0 is an incredibly useful tool for creating websites. You run it from the command line with a command such as

iisweb /create c:\ana\yeni1 "Site1" /b 80

In this command, C:\ana\yeni1 is the home folder for the website. You can create many websites programmatically using this tool, but it doesn't let you specify a Universal Naming Convention (UNC) path (e.g., \\deryapc\ana\yeni1) for the home directory. So, if you want to create websites whose home folders reside on shares, you can't use this tool.

Fortunately, it's easy to fool iisweb.vbs. I devised a solution that lets you use UNC paths for newly created websites. Let me give an example. Suppose the contents of several websites are located on a computer named Deryapc under a share named Ana. Under Ana there are separate folders for each of the websites. The folders are named yeni, yeni2, and yeni3. Although the websites' contents are on Deryapc, the websites are defined on a computer named Harunpc. Here are the steps to use a UNC path—\\deryapc\ana\yeni1—as the websites' home directory:

  1. Create a folder named Ana on Harunpc. This folder serves as a placeholder for the websites.
  2. Use iisweb.vbs to create the websites programmatically on Harunpc. In the creation process, specify C:\ana as the new websites' home folders, using the commands
    iisweb /create c:\ana\yeni1 "Site1" /b 80
    iisweb /create c:\ana\yeni2 "Site1" /b 80
    iisweb /create c:\ana\yeni3 "Site1" /b 80
  3. Stop the IIS services.
  4. Open the metabase.xml file in Notepad or another text editor. The metabase.xml file, which contains the IIS configuration parameters, resides in the C:\WINDOWS\system32\inetsrv\ folder. Change the home folder information by specifying \\deryapc\ana as the root folder instead of c:\ana.
  5. Restart the IIS services.

The new websites now point to the shares instead of the local folders.

I use this solution frequently, so I created the ReplaceInMetabase.vbs script in Listing 1 to edit the metabase.xml file.


Listing 1: ReplaceInMetabase.vbs (click to enlarge)

As callout A shows, the script replaces the old string c:\ana\ with the new string \\deryapc\ana\. To use this script, you simply need to customize the code in callout A with your old and new strings.

I also created another script, RefreshIIS.bat, which Listing 2 shows. This batch file stops the IIS services, runs ReplaceInMetabase.vbs (which edits the metabase.xml file), then restarts the IIS services.


Listing 2: RefreshIIS.bat

If you want to use the ReplaceInMetabase.vbs script instead of manually editing the metabase.xml file, follow these steps:

  1. Create a folder named Ana on Harunpc.
  2. Use iisweb.vbs to create the websites programmatically on Harunpc. In the creation process, specify C:\ana as the new websites' home folders.
  3. Run RefreshIIS.bat.

You can find the ReplaceInMetabase.vbs and RefreshIIS.bat scripts in the 102053.zip file, which you can download by clicking the Download the Code Here button at the top of the page.

End of Article



Reader Comments

You must be a registered user or online subscriber to comment on this article. Please log on before posting a comment. Are you a new visitor? Register now




Top Viewed ArticlesView all articles
Command Prompt Tricks

One reader shares his tip for setting up the command prompt to reflect a remote path. ...

WinInfo Short Takes: Week of November 23, 2009

An often irreverent look at some of the week's other news, including some post-PDC some soul searching, a Google Chrome OS announcement and a Microsoft response, Windows 7 off to a supposedly strong start, the Jonas Brothers and Xbox 360, and so much more ...

2009 Windows IT Pro Editors' Best and Community Choice Awards

Picking a favorite product from an impressive crowd of competitive offerings is never an easy task, and such was the case with our Editors' Best and Community Choice awards this year. ...


Related Articles Understanding IIS 7.0 Authentication

Configuring IIS 7.0 from the Command Line

6 New Security Features in IIS 7.0

Scripting IIS Administration

IIS and Web Administration Whitepapers Best Practices for SharePoint Backup & Recovery

From Development to Production: Streamlining SharePoint Deployment with DocAve Deployment Manager

Improve SharePoint Performance for Remote Workers

Related Events Deep Dive into Windows Server 2008 R2 presented by John Savill

7 Ways To Get More From Your SharePoint Deployment Now

Check out our list of Free Email Newsletters!

Scripting eBooks Keeping Your Business Safe from Attack: Encryption and Certificate Services

Best Practices for Managing Linux and UNIX Servers

Building an Effective Reporting System

Related Scripting Resources Introducing Left-Brain.com, the online IT bookstore
Looking for books, CDs, toolkits, eBooks? Prime your mind at Left-Brain.com

Discover Windows IT Pro eLearning Series!
Clear & detailed technical information and helpful how-to's, all in our trademark no-nonsense format


Windows IT Pro Home Register FAQ for Windows WinInfo News
Europe Edition About Us Contact Us/Customer Service Media Kit Affiliates / Licensing  
SQL Server Magazine Office & SharePoint Pro DevProConnections IT Job Hound
Left-Brain.com Technology Resource Directory asp.netPRO ITTV Windows SuperSite 
 
 Windows IT Pro is a Division of Penton Media Inc.
 © 2009 Penton Media, Inc. Terms of Use | Privacy Statement