62,046
社区成员
发帖
与我相关
我的任务
分享
serverID = "555";
serverComment = "Test";
defaultVrootPath = "D:\\Test";
HostName = "";
IP = "";
port = "80";
ManagementObject oW3SVC = new ManagementObject(_scope, new ManagementPath(@"IIsWebService='W3SVC'"), null);
//if (IsWebSiteExists(serverID))
//{
// return "Site Already Exists...";
//}
ManagementBaseObject inputParameters = oW3SVC.GetMethodParameters("CreateNewSite"); //error!!!!
ManagementBaseObject[] serverBinding = new ManagementBaseObject[1];
serverBinding[0] = CreateServerBinding(HostName, IP, Port);
inputParameters["ServerComment"] = serverComment;
inputParameters["ServerBindings"] = serverBinding;
inputParameters["PathOfRootVirtualDir"] = defaultVrootPath;
inputParameters["ServerId"] = serverID;
ManagementBaseObject outParameter = null;
outParameter = oW3SVC.InvokeMethod("CreateNewSite", inputParameters, null);
// 启动网站
string serverName = "W3SVC/" + serverID;
ManagementObject webSite = new ManagementObject(_scope, new ManagementPath(@"IIsWebServer='" + serverName + "'"), null);
webSite.InvokeMethod("Start", null);
return (string)outParameter.Properties["ReturnValue"].Value;
newVirDir.Properties["Path"].Insert(0, "D:\\Test");
newVirDir.Properties["Path"].Insert(0, "D:\\Test\\");
newVirDir.Properties["Path"].Value = "D:\\Test\\";
newVirDir.Properties["Path"].Value = "D:\\Test";
newVirDir.Properties["Path"][0] = "D:\\Test\\";
newVirDir.Properties["Path"][0]= "D:\\Test";