Monday, 13 August 2007

Multiple Websites In Windows XP Pro & IIS

Problem : You would like to create a new virtual site in IIS 5.1 on Windows XP Pro rather than a virtual directory. For example, you may want to do this when creating a site as a virtual directory is causing you problems with path offsets when referring to itself with absolute or relative paths. Surprisingly you find you can't add a virtual site through the IIS GUI - which is different to Windows 2000 and Windows Server 2003. So much for XP Pro being the all round development OS it was initially claimed to be! Solution : Whilst you can't add virtual servers through the GUI, Microsoft hasn't removed the functionality completely. You can create a virtual server through the following process using the command line. 1. Open command prompt and browse to the \Inetpub\AdminScripts directory 2. Create the new virtual server by typing:
   adsutil.vbs CREATE_VSERV W3SVC/i
where i is 'the number of virtual servers you currently have plus 1'. So if you only have the Default Web Site, enter:
   adsutil.vbs CREATE_VSERV W3SVC/2
* If you get prompted about wscripts & cscripts run the file as a cscript. 3. You can now use the IIS GUI to setup your new site!

More Info...

adsutil.vbs help

For more options with the adsutil.vbs script visit the Command-line Tools Included in IIS page or just type:
   adsutil.vbs help

Deleting a Virtual Server

To delete a virtual web site:
   adsutil.vbs DELETE W3SVC/i
where i is the number of the virtual server you wish to delete.

CScript VS WScript

CScript runs entirely in the command line and is ideal for non-interactive scripts. WScript has a Windows interface for user interaction.