Problem with system.management

L

Leszek

Hello!
I wrote a simple code to query WMI about few elements.
I'm trying to query it like SELECT my_definied_element FROM anyclass. Not
"*".
Can anyone help me? I know, that problem is with WMI collection...

Dim searcher As New ManagementObjectSearcher(provider, calosc)
Dim provider as string = "root\cimv2"
Dim wartosc as string() 'contains FreeSpace, Caption, Size, VolumeName
Dim element as string = ""
Dim calosc as string = "select FreeSpace, Caption, Size, VolumeName from
Win32_LogicalDisk where DriveType = '3' "
For Each queryObj As ManagementObject In searcher.Get()
'------------------------version A - working----------------------------
xmlWrite.WriteElementString(element, queryObj("Caption"))
xmlWrite.WriteElementString(element, queryObj("FreeSpace"))
'------------------------version B - not working - should------------
'For Each element In wartosc
'console.writeline(queryObj(element))
'console.writeline(---------------------------)
'Next
Next
 
L

Leszek

Ok. Everything is clear now.
I didn't trim wartosc from whitespaces...
Now works fine :)
 

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