This blog is a knowledge base...where I clip cool tricks and urls

Create / Edit Site

clipped from
namespace IIS6
public class SiteCreator {
static void Main() {
// path to root of virtual directory, is not created by creating the
string rootVirtualDir = "c:\\NewSite";
string site = "MySpecialSite";
ConnectionOptions oConn = new ConnectionOptions();
oConn.Username = "webAdministrator";
oConn.Password = "adminpwd";
ManagementPath myPath = new ManagementPath();
myPath.Server = "HostNameOfWebserver";
myPath.NamespacePath = @"root\MicrosoftIISv2";
myPath.RelativePath = "IIsWebService.Name='W3SVC'";
ManagementScope scope = new ManagementScope(myPath, oConn);
using (ManagementObject nac = new ManagementObject(scope, myPath, null))
// create a ServerBinding WMI object
ManagementObject Bindings = CreateInstance(oConn);
 blog it

No comments: