"Invalid use of Null" error when parsing WMI.

N

NightBreakA

Hello,
My company is deploying an application to customer PC's that
relies on the WMI framework to pull hardware ID's from the client
machine. The code we are using has worked flawless on over 60 seperate
installs, but we are running into this error on a couple of customer's
PC's, and I'm not sure where to proceed in troubleshooting this.
The PC's that are giving us the problem are running Windows 98 SE,
and Windows XP Home, respectively. The WMI installer goes through
flawlessly on the Win98SE machine, but even the most simple WMI query
will return "Invalid Use of NULL".
We created a testing app to see if WMI is functional on a PC, and
it is failing as well on these PC's. Below is the VB6 code for the
testing application.

Private Sub Command1_Click()
'Need the Proceesor Serial Number
Form1.MousePointer = 11
lblResults.Caption = ""
Dim strResuilt As String
Dim aryPath As Variant
Dim strPath As String
Dim strPathItem As Variant
Dim strProcessorID As String
Dim colitems As Object
Dim objItem As Object
strPath = Environ("Path")
MsgBox "The paths are as Follows: " & strPath
aryPath = Split(strPath, ";")
For Each strPathItem In aryPath
If InStr(1, UCase(strPathItem), "WBEM") <> 0 Then
MsgBox "The WBEM is there"
lblResults.Caption = "The Windows directory is there"
If Dir(strPathItem & "\Winmgmt.exe") <> "" Then
lblResults.Caption = lblResults.Caption & Chr(13) &
"The WMI exe is there."
Set colitems = GetObject("winmgmts:").ExecQuery("Select
* from Win32_Processor")
For Each objItem In colitems
strProcessorID = objItem.processorId
If strProcessorID <> "" Then
lblResults.Caption = lblResults.Caption &
Chr(13) & "WMI is working fine."
Exit For
End If
Next
Set colitems = Nothing
Set objItem = Nothing
End If
End If
Next
If lblResults.Caption = "" Then lblResults.Caption = "This program
did not find the WMI system"
Form1.MousePointer = 0
End Sub

Whenever we run this code on either affected PC, we are getting
"Invalid Use of NULL" whenever the program comes to the following line
of code:

Set colitems = GetObject("winmgmts:").ExecQuery("Select * from
Win32_Processor")

At this point, I'm suspecting either some kind of DLL mismatch, or
corrupted registry keys as the culprit, but I'm not even sure where to
begin on that. Any help will be greatly appreciated.

Thanks,
Mike Hilty
HLSM Parts and Accessories
(e-mail address removed)
 

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