Web Server Creator

Overview

Server creation, deletion, stopping, starting, configuring: These are all tasks that can keep you very busy, especially if you are an administrator of a large Internet or intranet Web site. This sample tool demonstrates how you can automate many of those tasks.

Code Tour

This sample script provides a simple interface through which you can create a new Web server. Several steps are required to accomplish this, starting with invoking GetObject on the IIS://LocalHost/W3SVC node. The IIsWebService object's ADSI method Create is used to create a new IIsWebServer object. The server object is then configured, and the new information written back to the metabase with the SetInfo method.

At this point in the script, the server is not a fully functional Web site. It now has a node in the metabase, but it is not running, nor does it have a root directory in which to store anything. To finish creating the Web site, the tool creates an instance of the IIsWebVirtualDir ADSI object, then configures that object to be the new root directory for the new server. SetInfo is once again called to save the information to the metabase, and finally, if all has gone well up to this point, the server object's Start method is invoked.

Remarks

Note that almost every major statement group in this sample has its own set of error-code checking. This is important when creating any tool in general, but especially for tools that use the IIS metabase.

Location

This script is available in the IIS samples directory, at ...\admin\mkwebsrv.vbs.