473,385 Members | 1,640 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,385 software developers and data experts.

Problem with system.management

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

Aug 16 '06 #1
1 865
Ok. Everything is clear now.
I didn't trim wartosc from whitespaces...
Now works fine :)

Użytkownik "Leszek" <ma***@zegarek.comnapisał w wiadomo¶ci
news:%2****************@TK2MSFTNGP03.phx.gbl...
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

Aug 16 '06 #2

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...
0
by: Talha | last post by:
Hi there, i installed POS for .NET SDK on a KIOSK machine. The problem that im getting is it runs perfectly well with the simulator devices that are provided with the sdk but even the sample...
9
by: scsharma | last post by:
hi, I am trying following code. string fileObject = @"C:\Documents and Settings\myfolder\Temp.txt"; ManagementBaseObject ret = null; ManagementPath path = new ManagementPath( ); path.Server =...
2
by: Dan | last post by:
I've written a short function to return the amount of free disk space on a specified drive (for example c:) and it works fine on my development platform. In production, however, I am getting an...
2
by: Christoph Borger | last post by:
Hello! I have wrote a windows service in vb.net. This service monitors the running processes with WMI and the Win32_Process class. Till last month all seems ok. But since the begin of september...
1
by: lcifers | last post by:
I have an application that uses the following code to return the default printer: Dim moReturn As Management.ManagementObjectCollection Dim moSearch As Management.ManagementObjectSearcher Dim...
0
by: Christian Havel | last post by:
Hi, I retrieve the following calling list when a exception appears in ReleaseComObject. mscorlib.dll!System.Runtime.InteropServices.Marshal.ReleaseComObject(System.Object o = <Nicht...
1
by: MollocH | last post by:
Hi NG, Here some Code: ------------------------------------------------------ Public Class Form1 Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles...
2
by: Vadim Malishev | last post by:
Hello, Can anybody help to solve the following problem? My Windows Service trying to access remote machine to get WindowsDirectory Property over Win32_OperatingSystem WMI class. Both servers...
2
by: BobLewiston | last post by:
Some of you may have seen my earlier thread “PasswordHash NULL problem”. I’ve started a new thread because investigation has shown that the problem is actually quite different than I previously...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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...

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.