views:

255

answers:

5

We have web application portal that hosts multiple applications each in with its own IIS Website. So each time we adopt another machine to run our code, either developer workstation, or server, we have to manully create all of the websites for each of our applications, (and of course the list just keeps on growing). Is there an API call to create an IIS website, so that I could store all the necessary info in a database table and then write a winforms program that would check the table, and automagically create one IIS website for each record?

+1  A: 

When IIS is installed onto a server, there are a number of scripts installed as well. The one to look at is IISweb.vbs as this enables you to create a website from the command line. It's typically located in your %Windows%\System32 directory and you can run it from a command prompt using Cscript iisweb.vbs sitename /d hostheader

If you need to set further parameters on your website, then there are a couple of ways of doing it, either use the adsutil.vbs utility script or create your dummy website, export the settings to a file (save configuration to a file) and then when you need to create a new website, get your program to edit the settings and then import the configuration as a new website.

A good place to look for some of this is in the IIS 6.0 Administration guide

Obviously to do this, you will need to have the appropriate permissions on the servers where you are creating the new websites

Cheshire Cat
A: 

You can create installators for your WebSites and run this insallators manualy or in batch. To create installators you can use WiX link text or standard Visual Studio Setup Project. Wix is more powerfull, but easiest way to start is to creating Visual Studio Installation project .

dario
A: 

Another useful script is adsutil.vbs in C:\Inetpub\AdminScripts

What version of IIS are you using? For IIS 6: http://www.microsoft.com/technet/prodtechnol/WindowsServer2003/Library/IIS/d3df4bc9-0954-459a-b5e6-7a8bc462960c.mspx?mfr=true

Axl
A: 

You can use SDC Tasks Library for that purpose. Here is a little manual.

Li0liQ
+1  A: 

If you wanted to do this in a WinForms/Console application then I'd highly recommend looking at the System.DirectoryServices namespace.

There's some good documentation here:

Using System.DirectoryServices to Configure IIS (MSDN)

For example, to create sites and virtual directories:

Creating Sites and Virtual Directories Using System.DirectoryServices (MSDN)

The System.DirectoryServices namespace is a managed wrapper around the ADSI API's that the various IIS administration scripts use.

For more information on the various metabase properties you'll encounter I recommend this reference:

IIS Metabase Properties (MSDN)

If or when you move onto IIS7 then I recommend taking a look at the Microsoft.Web.Administration namespace and the APPCMD tool.

Kev