WMI remote connection slow - help.

G

Guest

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 ConnectToConfigProv(string host, string
managementClass)
{
ManagementClass Config;
try
{
ConnectionOptions options = new ConnectionOptions();
options.Impersonation = ImpersonationLevel.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 RemoteRegistryReadValue(string sServer)
{
ManagementClass ManageConfig;
string sValue = null;
string sErrMsg = null;
string mgmtPath = "Win32_OperatingSystem";

ManageConfig= ConnectToConfigProv(sServer, mgmtPath);
if (ManageConfig== null)
{
sErrMsg = "WMI connection to \"Win32_OperatingSystem\" of
computer " + sServer + " failed";
//throw (new Exception(sErrMsg));
}
else
{
sValue = "There is no WMI, must be controller";
}

return sValue;

}


thanks
 
W

Willy Denoyette [MVP]

| 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 ConnectToConfigProv(string host, string
| managementClass)
| {
| ManagementClass Config;
| try
| {
| ConnectionOptions options = new ConnectionOptions();
| options.Impersonation = ImpersonationLevel.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 RemoteRegistryReadValue(string sServer)
| {
| ManagementClass ManageConfig;
| string sValue = null;
| string sErrMsg = null;
| string mgmtPath = "Win32_OperatingSystem";
|
| ManageConfig= ConnectToConfigProv(sServer, mgmtPath);
| if (ManageConfig== null)
| {
| sErrMsg = "WMI connection to \"Win32_OperatingSystem\" of
| computer " + sServer + " failed";
| //throw (new Exception(sErrMsg));
| }
| else
| {
| sValue = "There is no WMI, must be controller";
| }
|
| return sValue;
|
| }
|
|
| thanks

What are "controllers (no OS)" and are you sure about the 60 minutes? The
connection time-out is much lower. What happens if you try using Wbemtest or
WMIStudio (from the WMI tools kit).


Willy.
 
G

Guest

it's a third party controller(alarm, signal) and it does have an IPaddress.
From the domain controller I have to filter out the third party controller
and set the service start/stop on a real computer.
My question is: if there is no WMI on the third party controller, where is
the code failed?
failed here -> ManagementScope scope = new ManagementScope(sPath, options);
OR
-> scope.connect();
does it return anything?
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top