Hi,
I have 7 computers and 5 controllers(no OS) connected to Domain controller.
when I used WMI to query for registry, it take a long time (about 60
minutes) to return the result. if it a controller then there is no WMI and
return a NULL ManagementClass . Does anyone know there is another way to make
it run faster?
protected static ManagementClass ConnectToConfig Prov(string host, string
managementClass )
{
ManagementClass Config;
try
{
ConnectionOptio ns options = new ConnectionOptio ns();
options.Imperso nation = ImpersonationLe vel.Impersonate ;
string sPath = "\\\\" + host + "\\root\\cimv2" ;
ManagementScope scope = new ManagementScope (sPath, options);
scope.Connect() ;
Config = new ManagementClass (
scope,
new ManagementPath( managementClass ),
null);
}
catch
{
sErr = "WMI connection failed";
return Config=null;
//throw (new Exception(sErr) );
}
return Config;
}
public string RemoteRegistryR eadValue(string sServer)
{
ManagementClass ManageConfig;
string sValue = null;
string sErrMsg = null;
string mgmtPath = "Win32_Operatin gSystem";
ManageConfig= ConnectToConfig Prov(sServer, mgmtPath);
if (ManageConfig== null)
{
sErrMsg = "WMI connection to \"Win32_Operati ngSystem\" of
computer " + sServer + " failed";
//throw (new Exception(sErrM sg));
}
else
{
sValue = "There is no WMI, must be controller";
}
return sValue;
}
thanks
I have 7 computers and 5 controllers(no OS) connected to Domain controller.
when I used WMI to query for registry, it take a long time (about 60
minutes) to return the result. if it a controller then there is no WMI and
return a NULL ManagementClass . Does anyone know there is another way to make
it run faster?
protected static ManagementClass ConnectToConfig Prov(string host, string
managementClass )
{
ManagementClass Config;
try
{
ConnectionOptio ns options = new ConnectionOptio ns();
options.Imperso nation = ImpersonationLe vel.Impersonate ;
string sPath = "\\\\" + host + "\\root\\cimv2" ;
ManagementScope scope = new ManagementScope (sPath, options);
scope.Connect() ;
Config = new ManagementClass (
scope,
new ManagementPath( managementClass ),
null);
}
catch
{
sErr = "WMI connection failed";
return Config=null;
//throw (new Exception(sErr) );
}
return Config;
}
public string RemoteRegistryR eadValue(string sServer)
{
ManagementClass ManageConfig;
string sValue = null;
string sErrMsg = null;
string mgmtPath = "Win32_Operatin gSystem";
ManageConfig= ConnectToConfig Prov(sServer, mgmtPath);
if (ManageConfig== null)
{
sErrMsg = "WMI connection to \"Win32_Operati ngSystem\" of
computer " + sServer + " failed";
//throw (new Exception(sErrM sg));
}
else
{
sValue = "There is no WMI, must be controller";
}
return sValue;
}
thanks
Comment