Crafty
Member
I have created a simple a simple function that collects the software list from a specific machine on the network. It is still in draft format.
The problem is that it only tells me "general error", nothing more. So how do i know what I did wrong?
to test,
Add Ref system.management.dll
add imports
The problem is that it only tells me "general error", nothing more. So how do i know what I did wrong?
to test,
Add Ref system.management.dll
add imports
VB.NET:
Function EnumSoftwareList(ByVal strPC As String, ByVal Delimiter As Char, ByVal Department As String) As Collection
Dim strDetail As New Collection
Dim objWMISearch As ManagementObjectSearcher
Dim colItems As ManagementObjectCollection
Dim objItem As ManagementObject
Dim objWMI As ManagementScope = New ManagementScope("\\" & strPC & "\root\cimv2")
Dim strQuery As String = "Select * From Win32_Product"
Try
objWMI.Connect()
objWMISearch = New ManagementObjectSearcher(objWMI.Path.ToString, strQuery)
colItems = objWMISearch.Get
For Each objItem In colItems
Dim line As String = ""
line = objItem.GetPropertyValue("Name") & Delimiter & _
objItem.GetPropertyValue("Description") & Delimiter & _
objItem.GetPropertyValue("IdentifyingNumber") & Delimiter & _
objItem.GetPropertyValue("Version") & Delimiter & _
Department & Delimiter
strDetail.Add(line)
Debug.WriteLine("Name: " & objItem.GetPropertyValue("Name") & vbNewLine & _
"Caption: " & objItem.GetPropertyValue("Caption") & vbNewLine & _
"Description: " & objItem.GetPropertyValue("Description") & vbNewLine & _
"IdentifyingNumber: " & objItem.GetPropertyValue("IdentifyingNumber") & vbNewLine & _
"Version: " & objItem.GetPropertyValue("Version") & vbNewLine)
Next
Catch ex As Exception
Dim ErrorMSG As String
ErrorMSG = "An Error has occured:" & vbNewLine & ex.Message
MessageBox.Show(ErrorMSG, "Failed Enumurating Software", MessageBoxButtons.OK, MessageBoxIcon.Warning)
strDetail = Nothing
End Try
Return strDetail
End Function