WMI remote connection slow - help.

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • ttan

    WMI remote connection slow - help.

    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
  • Willy Denoyette [MVP]

    #2
    Re: WMI remote connection slow - help.


    "ttan" <ttan@discussio ns.microsoft.co mwrote in message
    news:985EACDF-ADCE-4F0D-8552-BB03FBED799E@mi crosoft.com...
    | 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

    What are "controller s (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.


    Comment

    • ttan

      #3
      Re: WMI remote connection slow - help.


      it's a third party controller(alar m, 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?


      "Willy Denoyette [MVP]" wrote:
      >
      "ttan" <ttan@discussio ns.microsoft.co mwrote in message
      news:985EACDF-ADCE-4F0D-8552-BB03FBED799E@mi crosoft.com...
      | 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
      >
      What are "controller s (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.
      >
      >
      >

      Comment

      Working...