sp; mo.Path = new ManagementPath(this.strPath+".Name=\""+serverNames[i]+"\"");
services[i,0] = (string)mo["Name"];
services[i,1] = (string)mo["DisplayName"];
services[i,2] = (string)mo["State"];
services[i,3] = (string)mo["StartMode"];
}
return services;
}
// 停止指定的服务
public string StartService(string serviceName)
{
string strRst = null;
ManagementObject mo = this.managementClass.CreateInstance();
mo.Path = new ManagementPath(this.strPath+".Name=\""+serviceName+"\"");
try
{
if((string)mo["State"]=="Stopped")//!(bool)mo["AcceptStop"]
mo.InvokeMethod("StartService",null);
}
catch(ManagementException e)
{
strRst =e.Message;
}
return strRst;
}