Skip navigation

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

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.

Hide comments

Comments

  • Allowed HTML tags: <em> <strong> <blockquote> <br> <p>

Plain text

  • No HTML tags allowed.
  • Web page addresses and e-mail addresses turn into links automatically.
  • Lines and paragraphs break automatically.
Publish