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

The iisweb.vbs script that comes with IIS 6.0 is an incredibly useful tool for creating websites. However, you can't use it to create websites whose home folders reside on shares. Here's a workaround.

Murat Yildirimoglu

June 3, 2009

2 Min Read
ITPro Today logo in a gray background | ITPro Today


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:anayeni1 "Site1" /b 80

In this command, C:anayeni1 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., \deryapcanayeni1) 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—\deryapcanayeni1—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:anayeni1 "Site1" /b 80iisweb /create c:anayeni2 "Site1" /b 80iisweb /create c:anayeni3 "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:WINDOWSsystem32inetsrv folder. Change the home folder information by specifying \deryapcana 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 \deryapcana. 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.

Sign up for the ITPro Today newsletter
Stay on top of the IT universe with commentary, news analysis, how-to's, and tips delivered to your inbox daily.

You May Also Like