Creating Multiple IIS Websites in one go

On January 14, 2010, in ColdFusion, Web Development, by Anuj Gakhar

I was assigned a task, recently, whereby I was given a list of about 100 domain names and I had to create all those websites on a fresh installation of IIS 6.0.  Naturally, I started looking for some kind of tool that would do this for me. After spending some time on search and asking a few people, I realized , there is no such tool (correct me if I am wrong here).

So, I thought of writing a little ColdFusion script that would do this for me. Turns out it wasnt that bad at all and it worked like a charm.

Here is the script I wrote.

<cfset sites = ["",""] />
<!— I have removed the actual site names from the list above—>

<!— loop over all the sites—>
<cfloop from="1" to="#arraylen(sites)#" index="i">
<!— see if the site folder exists—>
<cfset thisSite = sites[i] />
<cfset site_path = "c:/websites/#thisSite#">
<cfif NOT DirectoryExists(site_path)>
<!— create if does not exist already—>
<cfdirectory action="create" directory="#site_path#" />

<!— construct the IIS site creation command—>
<cfset iis_cmd = "c:\windows\system32\" & ‘iisweb.vbs /create c:\websites\#thisSite# "#thisSite#" /i IP_ADDRESS_HERE /d #thisSite# ‘>
<cfexecute name="c:\windows\system32\cscript.exe" arguments="#iis_cmd#" timeout="30" variable="strResult" />
<cfdump var = "#strResult#">


I took help from this article, which details the different attributes of the iisweb.vbs command-line utility.


6 Responses to Creating Multiple IIS Websites in one go

  1. Tunc says:

    Is this for 1 IP address for all the websites?

  2. Anuj Gakhar says:

    Yes I wanted it that way but you can change that to any IP or any host header.

  3. rad_g says:

    iisweb.vbs does not exist on windows 2008. on win2008 use powershell with microsoft.web.administration and

  4. Anuj Gakhar says:

    Radek, thanks for the info. I was actually using this on Win2003 Server. But if I happen to do it on 2008, I will keep this in mind. Hows it going these days ?

  5. Lorna says:

    Thanks for sharing this script, it is very helpful.

  6. You are amazing! Where did you learn to write such things??

    Thank you for sharing!

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Subscribe to Blog via Email

Enter your email address to subscribe to this blog and receive notifications of new posts by email.

Join 446 other subscribers

© 2011 Anuj Gakhar
%d bloggers like this: