WMI getting disk information problem

supermanzdead

Active member
Joined
Feb 23, 2006
Messages
31
Programming Experience
Beginner
VB.NET:
[SIZE=2][/SIZE][SIZE=2][COLOR=#0000ff]Function[/COLOR][/SIZE][SIZE=2] GetDriveSpace([/SIZE][SIZE=2][COLOR=#0000ff]ByVal[/COLOR][/SIZE][SIZE=2] computername [/SIZE][SIZE=2][COLOR=#0000ff]As[/COLOR][/SIZE][SIZE=2] [/SIZE][SIZE=2][COLOR=#0000ff]String[/COLOR][/SIZE][SIZE=2])
[/SIZE][SIZE=2][COLOR=#0000ff]Dim[/COLOR][/SIZE][SIZE=2] objLD [/SIZE][SIZE=2][COLOR=#0000ff]As[/COLOR][/SIZE][SIZE=2] Management.ManagementQuery
objLD = [/SIZE][SIZE=2][COLOR=#0000ff]New[/COLOR][/SIZE][SIZE=2] Management.ObjectQuery([/SIZE][SIZE=2][COLOR=#800000]"SELECT * FROM Win32_LogicalDisk"[/COLOR][/SIZE][SIZE=2])
[/SIZE][SIZE=2][COLOR=#0000ff]Dim[/COLOR][/SIZE][SIZE=2] objWMIService [/SIZE][SIZE=2][COLOR=#0000ff]As[/COLOR][/SIZE][SIZE=2] Management.ManagementScope
objWMIService = [/SIZE][SIZE=2][COLOR=#0000ff]New[/COLOR][/SIZE][SIZE=2] Management.ManagementScope([/SIZE][SIZE=2][COLOR=#800000]"\\"[/COLOR][/SIZE][SIZE=2] & computername & [/SIZE][SIZE=2][COLOR=#800000]"\root\cimv2"[/COLOR][/SIZE][SIZE=2])
objWMIService.Connect()
[/SIZE][SIZE=2][COLOR=#0000ff]Dim[/COLOR][/SIZE][SIZE=2] searcher [/SIZE][SIZE=2][COLOR=#0000ff]As[/COLOR][/SIZE][SIZE=2] Management.ManagementObjectSearcher
searcher = [/SIZE][SIZE=2][COLOR=#0000ff]New[/COLOR][/SIZE][SIZE=2] Management.ManagementObjectSearcher(objWMIService, objLD)
[/SIZE][SIZE=2][COLOR=#0000ff]Dim[/COLOR][/SIZE][SIZE=2] queryCollection [/SIZE][SIZE=2][COLOR=#0000ff]As[/COLOR][/SIZE][SIZE=2] Management.ManagementObjectCollection
queryCollection = searcher.Get
[/SIZE][SIZE=2][COLOR=#0000ff]Dim[/COLOR][/SIZE][SIZE=2] m [/SIZE][SIZE=2][COLOR=#0000ff]As[/COLOR][/SIZE][SIZE=2] Management.ManagementObject
[/SIZE][SIZE=2][COLOR=#0000ff]For[/COLOR][/SIZE][SIZE=2] [/SIZE][SIZE=2][COLOR=#0000ff]Each[/COLOR][/SIZE][SIZE=2] m [/SIZE][SIZE=2][COLOR=#0000ff]In[/COLOR][/SIZE][SIZE=2] queryCollection
[/SIZE][SIZE=2][COLOR=#0000ff]Return[/COLOR][/SIZE][SIZE=2] MessageBox.Show(m([/SIZE][SIZE=2][COLOR=#800000]"systemname"[/COLOR][/SIZE][SIZE=2]) & vbCrLf & m([/SIZE][SIZE=2][COLOR=#800000]"name"[/COLOR][/SIZE][SIZE=2]) & [/SIZE][SIZE=2][COLOR=#800000]" "[/COLOR][/SIZE][SIZE=2] & Int(m([/SIZE][SIZE=2][COLOR=#800000]"size"[/COLOR][/SIZE][SIZE=2]) / 1073741824) & [/SIZE][SIZE=2][COLOR=#800000]" GB"[/COLOR][/SIZE][SIZE=2] & [/SIZE][SIZE=2][COLOR=#800000]" / "[/COLOR][/SIZE][SIZE=2] & [/SIZE][SIZE=2][COLOR=#800000]"Free Space: "[/COLOR][/SIZE][SIZE=2] & Int(m([/SIZE][SIZE=2][COLOR=#800000]"freespace"[/COLOR][/SIZE][SIZE=2]) / 1073741824) & [/SIZE][SIZE=2][COLOR=#800000]" GB"[/COLOR][/SIZE][SIZE=2])
[/SIZE][SIZE=2][COLOR=#0000ff]Next
[/COLOR][/SIZE][SIZE=2][/SIZE][SIZE=2][COLOR=#0000ff]Return[/COLOR][/SIZE][SIZE=2] [/SIZE][SIZE=2][COLOR=#0000ff]Nothing
[/COLOR][/SIZE][SIZE=2][/SIZE][SIZE=2][COLOR=#0000ff]End[/COLOR][/SIZE][SIZE=2] [/SIZE][SIZE=2][COLOR=#0000ff]Function[/COLOR][/SIZE]
[SIZE=2][COLOR=#0000ff]
[/COLOR][/SIZE]

Code above works fine but only gets the first drive, doesnt cycle through the rest of the drives, what am I missing? (I am sure it is something goofy or I am way off...either way any help is appreciated)

 
uh nevermind I am being silly again, just realized that it was showing just the last drive's information cause I didn't use the appendtext method :)

all figured out for now...thanks for anyone who took a look though!
 
Back
Top