Web共享
DirectoryEntry ent = new DirectoryEntry("IIS://oh35d-install1/w3svc");
DirectoryEntry entchild = new DirectoryEntry();
entchild = ent.Children.Add("5","IIsWebServer");
entchild.CommitChanges();
entchild.Properties["ServerBindings"].Value = ":123:";
entchild.Properties["ServerState"].Value = 2;
entchild.Properties["ServerComment"].Value = "TESTSITE";
entchild.CommitChanges();
DirectoryEntry vdir = entchild.Children.Add("ROOT","IIsWebVirtualDir");
vdir.CommitChanges();
vdir.Properties["AppIsolated"].Value = 2;
vdir.Properties["Path"].Value = @"C:\Inetpub\wwwroot";
vdir.Properties["AuthFlags"].Value = 5;
vdir.Properties["DirBrowseFlags"].Value = 1073741886;
vdir.Properties["AccessFlags"].Value = 513;
vdir.CommitChanges();
entchild.CommitChanges();
ent.CommitChanges();