mustafa levrek

mustafa levrek

  • NA
  • 9
  • 608

Remote Connection before WMI queries takes too long. How to fasten?

Dec 26 2021 12:58 PM

I am making WMI queries to remote computers that are in our production network. The first connection with ManegementScope takes realy long. (8-10 seconds)  If the first connection is done the next connection is then much faster. How can i speed up this connection time. That's the code i am using:


public void WMI_Connect()
{

System.Management.ConnectionOptions options = new System.Management.ConnectionOptions();
options.Username = "user";
options.Password = "password";
WMI_path = "\\\\" + MAE_Selection.MAE_IP_PCU + "\\root\\cimv2";
ManagementScope scope = new ManagementScope(WMI_path, options);

try
{
// Start WMIconnect
scope.Connect();
// WMI Connection done ( takes 8-10 seconds !!!)

// The method in that i am doing the WMI queries. The WMI query method takes less then 1 second
Read_General_Data_WMI();


}
catch (Exception ex)
{
using (StreamWriter sw = File.AppendText((Start.error_path)))
{
sw.WriteLine(ex);
WMI_Con_State = "Connection_failed";
}
}
}