|
-
Mar 17th, 2007, 03:11 PM
#1
Thread Starter
Member
[2005] Improving speed of WMI calls
Hello everyone,
I am still learning how to integrate wmi into vb.net,
I was able today to write a program which can retrieve installed software from a remote computer. The issue is that the process took over 30 seconds which is some how high.
Is there any technique to improve this ?
Thank you
Best Regards
-
Mar 17th, 2007, 07:09 PM
#2
Re: [2005] Improving speed of WMI calls
It's hard to make code better if you haven't seen the code.
-
Mar 18th, 2007, 02:50 AM
#3
Thread Starter
Member
Re: [2005] Improving speed of WMI calls
 Originally Posted by jmcilhinney
It's hard to make code better if you haven't seen the code.
Sorry for that, the program is still very simple and i am using it for testing.
The program should retrieve the list of installed software.
Code:
Imports System.Management
Module Module1
Sub Main()
Dim myconnectionoptions As New System.Management.ConnectionOptions
With myconnectionoptions
.Impersonation = ImpersonationLevel.Impersonate
.Authentication = AuthenticationLevel.Packet
End With
Dim managementscope As System.Management.ManagementScope
managementscope = New System.Management.ManagementScope("\\192.168.1.3\root\cimv2", myconnectionoptions)
managementscope.Connect()
If managementscope.IsConnected = True Then
Console.WriteLine("Connection Established")
Else
Console.WriteLine("COULD NOT CONNECT")
End If
Dim myobjectsearcher As System.Management.ManagementObjectSearcher
Dim mycollection As System.Management.ManagementObjectCollection
Dim myobject As System.Management.ManagementObject
myobjectsearcher = New System.Management.ManagementObjectSearcher(managementscope.Path.ToString, "Select * from Win32_Product") 'Win32_Product
mycollection = myobjectsearcher.Get
For Each myobject In mycollection
Console.WriteLine(myobject.GetPropertyValue("Caption"))
Next
Console.ReadLine()
End Sub
End Module
Thanks
-
Mar 18th, 2007, 03:07 AM
#4
Re: [2005] Improving speed of WMI calls
You should step through the code one line at a time and see what parts take a long time. You can also time each step and output the results to the Output window or a log file or whatever. You can't always fix code by looking at it. Just like a machine you have to run it and analyse its performance in action.
-
Mar 18th, 2007, 03:16 AM
#5
Thread Starter
Member
Re: [2005] Improving speed of WMI calls
The part taking the most time is when you query the machine for the installed software. So I think u mean its not the code that is slow but the querying process and retrieving the data..
I tried to query a machine with 30+ programs so maybe thats why it took sometime.
Thanks jmcilhinney.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|