WMI script to get Win32_Product

B

Brian Henry

I have this script

Dim query As New ManagementObjectSearcher("Select * from Select * from
Win32_Product")

Debug.Write(query.Get().Count)

For Each mo As ManagementObject In query.Get

Me.ListBox1.Items.Add(mo("Name"))

Next



but it returns nothing, however other WMI scripts work fine...This should
list all the software instaled on a system. Why does it return nothing?
 
G

Guest

Hi,

I never have had any problems with using Win32_Product. I would suspect
it has something to do with your query.

Select * from Select * from Win32_Product

Should be

Select * from Win32_Product

Ken
 
B

Brian Henry

whoops i retyped it wrong..

has nothing to do with the query, In code it is only "select * from
Win32_Product", what happens is when i step through it line by line, when it
hits this line

For Each mo As ManagementObject In query.Get

the execution of the sub just stops and it jumps out of the sub... execute
query.get on its own line and the same thing happens, no code is executed
after that statement in the sub... (this is on win xp pro 64-bit edition, in
..NET 2.0) so when i step to that line .. press the button for stepping on
the line to step again it just jumps from that line and out of the sub... im
just confused... when i do any other WMI query they execute perfectly fine..
 
B

Brian Henry

fixed it turned out WMI isnt installed on 64bit windows xp by default
*rolles eyes* because its based on windows server not xp..
 
K

Ken Tucker [MVP]

Brian,

The WMI is installed with xp pro x64. I really dont understand
why it is not working on your system because the code ran fine on my xp x64
pro system.

Ken
---------------
 
B

Brian Henry

strange, on mine when I added WMI under the list of managment objects I
could install in add programs for windows, it started to work, removed it,
it stoped working...
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top