Subscribe to Windows IT Pro

 

Get Newsletters

  • Get the Latest News
  • Product Updates
  • Helpful Tricks
  • Productivity Tips

Subscribe Now!

June 04, 2009 12:00 AM

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

Windows IT Pro
InstantDoc ID #102053
Rating: (1)
Downloads
102053.zip

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.

Related Content:

ARTICLE TOOLS

Comments
    There are no comments to display. Be the first one!
You must log on before posting a comment.

Are you a new visitor? Register Here

advertisement

advertisement

White Papers

Get your Windows 7 deployment off to the right start by implementing PC lockdown. A locked-down environment is easier and cheaper to support since users are less likely to make unnecessary changes to the core system configuration - read more here!

Essential Guides

Is your iSCSI "lossy"? The reality is that most off-the-shelf Ethernet hardware deployed for iSCSI can lose packets, resulting in slow performance or application downtime. Learn how to assess your current iSCSI infrastructure and engineer an advanced iSCSI SAN infrastructure.

Web Seminars

What's the best way to keep your network safe from malware? In this web seminar, security expert Greg Shields suggests an alternative method to the traditional blacklisting approach that is common with anti-virus and anti-malware solutions.

eLearning Series

We bring the experts direct to you to share their real-world perspective and expertise. During each event, three sessions stream in real time, so you can learn, ask questions, and get solutions.
Upcoming event: Getting the Most with Exchange 2010 with Paul Robichaux

Subscribe to Windows IT Pro!

Windows is a trademark of the Microsoft group of companies. Windows IT Pro is used by Penton Media Inc. under license from owner.