bsp; connectionOptions.Password = password;
ManagementScope managementScope = new ManagementScope( "\\\\" +host+ "\\root\\cimv2",connectionOptions) ;
this.managementClass.Scope = managementScope;
}
}
// 验证是否能连接到远程
计算机 public static bool RemoteConnectValidate(string host,string userName,string password)
{
ConnectionOptions connectionOptions = new ConnectionOptions();
connectionOptions.Username = userName;
connectionOptions.Password = password;
ManagementScope managementScope = new ManagementScope( "\\\\" +host+ "\\root\\cimv2",connectionOptions) ;
try
{
managementScope.Connect();
}
catch
{
}
return managementScope.IsConnected;
}
// 获取指定服务属性的值
public object GetServiceValue(string serviceName,string propertyName)
{
ManagementObject mo = this.managementClass.CreateInstance();
mo.Path = new ManagementPath(this.strPath+".Name=\""+serviceName+"\"");
return mo[prope