Home All Groups Group Topic Archive Search About

WMI script to get Win32_Product

Author
3 Apr 2006 1:19 PM
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?

Author
3 Apr 2006 2:56 PM
Ken Tucker [MVP]
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
-------------------------
Show quoteHide quote
"Brian Henry" wrote:

> 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?
>
>
>
Author
3 Apr 2006 3:18 PM
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..
Author
3 Apr 2006 7:08 PM
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..

Show quoteHide quote
"Brian Henry" <nospam@nospam.com> wrote in message
news:ODIXaHzVGHA.5172@TK2MSFTNGP12.phx.gbl...
> 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..
>
Author
3 Apr 2006 10:49 PM
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
---------------
Show quoteHide quote
"Brian Henry" <nospam@nospam.com> wrote in message
news:eBFi8H1VGHA.1764@TK2MSFTNGP11.phx.gbl...
> fixed it turned out WMI isnt installed on 64bit windows xp  by default
> *rolles eyes* because its based on windows server not xp..
>
> "Brian Henry" <nospam@nospam.com> wrote in message
> news:ODIXaHzVGHA.5172@TK2MSFTNGP12.phx.gbl...
>> 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..
>>
>
>
Author
3 Apr 2006 11:44 PM
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...

Show quoteHide quote
"Ken Tucker [MVP]" <vb***@bellsouth.net> wrote in message
news:ug982D3VGHA.2952@TK2MSFTNGP11.phx.gbl...
> 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
> ---------------
> "Brian Henry" <nospam@nospam.com> wrote in message
> news:eBFi8H1VGHA.1764@TK2MSFTNGP11.phx.gbl...
>> fixed it turned out WMI isnt installed on 64bit windows xp  by default
>> *rolles eyes* because its based on windows server not xp..
>>
>> "Brian Henry" <nospam@nospam.com> wrote in message
>> news:ODIXaHzVGHA.5172@TK2MSFTNGP12.phx.gbl...
>>> 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..
>>>
>>
>>
>
>