Simple Question Using WMI in VB 2005 .Net
Posted on 2007-08-03
Hey Again Everyone,
I was looking at some of the discussion threads on EE regarding using WMI to obtain USB information. Some of the threads seemed to have full solutions like the one I've pasted at the end of this question. When I cut/paste this into VB 2005, it keeps telling me that the managementobjectsearch, managementobtect and managementobjectcollection is not defined. Do I need to somehow "initialize" the managementobjects?
Function GetInfo(ByVal strServer As String)
Dim strDetail As String
Dim objWMISearch As ManagementObjectSearcher
Dim colItems As ManagementObjectCollection
Dim objItem As ManagementObject
Dim objWMI As ManagementScope = New ManagementScope("\\" & strServer & "\root\cimv2")
Dim strQuery As String = "Select * From Win32_OperatingSystem"
objWMISearch = New ManagementObjectSearcher(objWMI.Path.ToString, strQuery)
colItems = objWMISearch.Get
For Each objItem In colItems