473,793 Members | 2,894 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

ManagementClass .GetInstances() takes a long time

I am calling the method GetInstances() within the ManagementClass . I have 48
applications on my system. Mearly calling the routine takes 28 seconds for
it to return. I don't understand why this method would take so long to
execute. I've tried setting the EnumerationOpti ons.EnumerateDe ep to false
but it doesn't seem to have any impact on the time. Can someone tell me how
to speed up the execution of this method?

--
Steve
Nov 17 '05 #1
4 5908

"Steve Teeples" <St**********@d iscussions.micr osoft.com> wrote in message
news:72******** *************** ***********@mic rosoft.com...
I am calling the method GetInstances() within the ManagementClass . I have
48
applications on my system. Mearly calling the routine takes 28 seconds
for
it to return. I don't understand why this method would take so long to
execute. I've tried setting the EnumerationOpti ons.EnumerateDe ep to false
but it doesn't seem to have any impact on the time. Can someone tell me
how
to speed up the execution of this method?

--
Steve


Mnd to tell us what instances your are trying to retrieve?

Willy.
Nov 17 '05 #2
Win32_Product.

I used the wbemtest.exe tool also just to see if my code somehow was slowing
it down and I see the same results with it. If you pull up all instances of
Win32_Product (I have 38 apps installed) it takes about 30 seconds for the
call to return. I'm iterating through many Win32_xxx classes and some of
these cause a massive delay in my app. I'm hoping to avoid the delay.

--
Steve
"Steve Teeples" wrote:
I am calling the method GetInstances() within the ManagementClass . I have 48
applications on my system. Mearly calling the routine takes 28 seconds for
it to return. I don't understand why this method would take so long to
execute. I've tried setting the EnumerationOpti ons.EnumerateDe ep to false
but it doesn't seem to have any impact on the time. Can someone tell me how
to speed up the execution of this method?

--
Steve

Nov 17 '05 #3
Here is a snipit of my code.

ManagementClass aClass = new ManagementClass (className);
if (aClass != null)
{
aClass.Scope = new ManagementScope (this.cimScope) ;
EnumerationOpti ons opts = new EnumerationOpti ons();
opts.EnumerateD eep = false;
opts.ReturnImme diately = false;
ManagementObjec tCollection instances = aClass.GetInsta nces(opts);
foreach (ManagementObje ct instance in instances)
{
... doing a string manipulation ...
}
}

--
Steve
"Willy Denoyette [MVP]" wrote:

"Steve Teeples" <St**********@d iscussions.micr osoft.com> wrote in message
news:72******** *************** ***********@mic rosoft.com...
I am calling the method GetInstances() within the ManagementClass . I have
48
applications on my system. Mearly calling the routine takes 28 seconds
for
it to return. I don't understand why this method would take so long to
execute. I've tried setting the EnumerationOpti ons.EnumerateDe ep to false
but it doesn't seem to have any impact on the time. Can someone tell me
how
to speed up the execution of this method?

--
Steve


Mnd to tell us what instances your are trying to retrieve?

Willy.

Nov 17 '05 #4
Ok I see "Win32_Product" , this is indeed a slow operation when executed the
first time.
WMI first retrieves a basic list of the installed products (using MSI), from
the "msi install server", and uses each item in the list to scan the
registry for product details, for this WMI has to map large portions of the
registry and that takes time. Once the services are running and the registry
portions are mapped the query returns somewhat faster, but this isn't of
great help of course.
I really don't see a way to speed up these queries the way it's designed.

Willy.

"Steve Teeples" <St**********@d iscussions.micr osoft.com> wrote in message
news:5E******** *************** ***********@mic rosoft.com...
Win32_Product.

I used the wbemtest.exe tool also just to see if my code somehow was
slowing
it down and I see the same results with it. If you pull up all instances
of
Win32_Product (I have 38 apps installed) it takes about 30 seconds for the
call to return. I'm iterating through many Win32_xxx classes and some of
these cause a massive delay in my app. I'm hoping to avoid the delay.

--
Steve
"Steve Teeples" wrote:
I am calling the method GetInstances() within the ManagementClass . I
have 48
applications on my system. Mearly calling the routine takes 28 seconds
for
it to return. I don't understand why this method would take so long to
execute. I've tried setting the EnumerationOpti ons.EnumerateDe ep to
false
but it doesn't seem to have any impact on the time. Can someone tell me
how
to speed up the execution of this method?

--
Steve

Nov 17 '05 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
14047
by: Paul Gronka | last post by:
I've got a VB.NET windows application (written in VS .NET 2003) that makes a call to WMI for retrieving the MAC Address from the client's PC. It works on 4 out of the 5 PC's tested so far. All the workstations are DELLs running XP SP1a with the 1.1 .NET Framework. The following line of code generates an exception on the one PC: Dim oMac As New System.Management.ManagementClass("Win32_NetworkAdapterConfiguration") The error it...
1
3186
by: Ryan Berry | last post by:
Hi there, We have created a custom adapter for Microsoft BizTalk using C#. We wish to add the adapter to the BizTalk adapters list automatically upon install and remove it on uninstall. We found this code, which seemed to do exactly what we want: geekswithblogs.net/cmcneill/ archive/2005/04/05/28336.aspx However, when running the Uninstall method, an exception is thrown at the
22
1562
by: Scot | last post by:
I have the following code: Dim IP, domainName As String domainName = "yahoo.com" Try IP = System.Net.Dns.GetHostByName(domainName).AddressList(0).ToString() Catch ex As Exception IP = "Not Valid" End Try
7
1711
by: Bruce D | last post by:
My program in connecting to a web site and I want to know how long it takes to connect to this site. I'm assuming I need to use some sort of timer. This is a console application. Here are the lines of code. ' set some time var Dim lWebRequest As System.Net.WebRequest = System.Net.WebRequest.Create(lURL) lWebRequest.Timeout = lTimeOut Dim lWebResponse As System.Net.WebResponse = lWebRequest.GetResponse() ' set second time var and...
3
23334
by: Anil Gupte | last post by:
I am getting this error: Type 'System.Management.ManagementClass' is not defined. The statement is: Dim diskClass As New System.Management.ManagementClass("Win32_LogicalDisk") According to the help file, this 'System.Management.ManagementClass' is under System.Object, so I put in the Imports System.Object in namespace, but that seems not to help.
0
2201
by: sachinrohamare | last post by:
I am getting following error while iterating through the ManagementObjectCollection: This error is coming only for the first time. From the 2nd run onwards the code is executed successfully. Surprisingly when I execute the code with the gap of 20-25 minutes the error is reproducible! Please provide the solution urgently. Thanks in Advance ! Please check the error details, sample C# code I am using. Regards,
2
3308
by: =?Utf-8?B?Qy4gSHVnaGVz?= | last post by:
Hi, I can't figure it out. A piece of code to obtain the Processor ID which has always worked fine, suddenly throws an UnauthorizedAccessException. I have changed absolutely nothing to my code, and nothing to my system. The same code works fine on a different computer. The code in question: string cpuInfo = String.Empty; ManagementClass mc = new ManagementClass("Win32_Processor"); ManagementObjectCollection moc = mc.GetInstances();
3
3549
by: =?Utf-8?B?QWxleGFuZGVyIFd5a2Vs?= | last post by:
My application is taking way too long to build. It use to never take so long. I change only line and I think it recompiles all the classes in the assembly because it hangs forever. Here is the compiler line from the output window during complication: Target CoreCompile: C:\WINDOWS\Microsoft.NET\Framework\v3.5\Csc.exe /noconfig /nowarn:1701,1702 /platform:x86 /errorreport:prompt /warn:4 /define:DEBUG;TRACE /main:AutoDeveloper.Program...
6
2108
by: Charles Law | last post by:
I have a data table with ~1000 rows. I go through the rows one at a time, checking the contents. If I find a cell with an error, e.g containing null, I use SetColumnError on the data row to flag it. Here's my code: For Each dr As DataRow In MyDataTable.Rows Dim MyValue As Integer If dr("ID").Equals(DBNull.Value) Then
0
9671
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9518
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10433
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10212
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
9035
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
5436
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
4112
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3720
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2919
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.