473,425 Members | 1,788 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,425 software developers and data experts.

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 EnumerationOptions.EnumerateDeep 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 5861

"Steve Teeples" <St**********@discussions.microsoft.com> wrote in message
news:72**********************************@microsof t.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 EnumerationOptions.EnumerateDeep 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 EnumerationOptions.EnumerateDeep 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);
EnumerationOptions opts = new EnumerationOptions();
opts.EnumerateDeep = false;
opts.ReturnImmediately = false;
ManagementObjectCollection instances = aClass.GetInstances(opts);
foreach (ManagementObject instance in instances)
{
... doing a string manipulation ...
}
}

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

"Steve Teeples" <St**********@discussions.microsoft.com> wrote in message
news:72**********************************@microsof t.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 EnumerationOptions.EnumerateDeep 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**********@discussions.microsoft.com> wrote in message
news:5E**********************************@microsof t.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 EnumerationOptions.EnumerateDeep 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
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...
1
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...
22
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...
7
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...
3
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...
0
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....
2
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,...
3
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...
6
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...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
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,...
0
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...
0
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,...
0
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...
1
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
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,...
0
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...

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.