日期:2014-05-18 浏览次数:20462 次
String appPoolName = "MyApp2"; DirectoryEntry newpool; DirectoryEntry apppools = new DirectoryEntry("IIS://localhost/W3SVC/AppPools"); newpool = apppools.Children.Add(appPoolName,"IIsApplicationPool"); newpool.Properties["AppPoolIdentityType"][0] = "2"; newpool.Properties["IdleTimeout"][0] = 0; newpool.Properties["MaxProcesses"][0] = 5; newpool.CommitChanges(); //创建网站 DirectoryEntry Service = new DirectoryEntry("IIS://localhost/W3SVC"); DirectoryEntry Server; int i = 0; IEnumerator ie = Service.Children.GetEnumerator(); while (ie.MoveNext()) { Server = (DirectoryEntry)ie.Current; if (Server.SchemaClassName == "IIsWebServer") { if (Convert.ToInt32(Server.Name) > i) i = Convert.ToInt32(Server.Name); } } i++; Server = Service.Children.Add(i.ToString(), "IIsWebServer"); Server.Properties["ServerBindings"].Value = ":8551:"; Server.Properties["ServerComment"][0] = "测试网站"; DirectoryEntry root = Server.Children.Add("Root", "IIsWebVirtualDir"); root.Properties["path"][0] = @"C:\b\xx"; Service.CommitChanges(); Server.CommitChanges(); root.CommitChanges(); //这里应该就是添加应用程序池的。。不知道这里不么改 object[] param = { 0, appPoolName, true }; root.Invoke("AppCreate3", param); Server.Invoke("start", new object[0]);
string ScriptMaps = @".asp,C:\WINDOWS\system32\inetsrv\asp.dll,5,GET,HEAD,POST,TRACE .cer,C:\WINDOWS\system32\inetsrv\asp.dll,5,GET,HEAD,POST,TRACE .cdx,C:\WINDOWS\system32\inetsrv\asp.dll,5,GET,HEAD,POST,TRACE .asa,C:\WINDOWS\system32\inetsrv\asp.dll,5,GET,HEAD,POST,TRACE .idc,C:\WINDOWS\system32\inetsrv\httpodbc.dll,5,GET,POST .shtm,C:\WINDOWS\system32\inetsrv\ssinc.dll,5,GET,POST .shtml,C:\WINDOWS\system32\inetsrv\ssinc.dll,5,GET,POST .stm,C:\WINDOWS\system32\inetsrv\ssinc.dll,5,GET,POST .asax,C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\aspnet_isapi.dll,5,GET,HEAD,POST,DEBUG .ascx,C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\aspnet_isapi.dll,5,GET,HEAD,POST,DEBUG .ashx,C:\WINDOWS\Microsoft.