Windows XP WMI Error

Joined
Aug 29, 2006
Messages
1
Reaction score
0
Hi All,

Please Help!!

I am using WMI to Access remote machine registry (Using Vb6), while reading the registry its giving me Shuting down error.Error code is - 2147217357.

The logic i am using is as below :

i am searching the regsitry for a given entry( a dll) , if that entry exist , i am unregistering the Dll and re-registering it. While Reading the registry code is falling over and the error is - Shutting down.(2147217357).

Please suggest.

Code section :(Red line shows the point where i am getting shutdown error)

'Find the entry of a given Dll on the remote machine
Public Function FindDllEntry(strEntry As String, strServer As String) As Boolean
Dim sValues As String
Dim sNames() As Variant
Dim iTypes As Variant
Dim lRC As Long
Dim i As Integer
Dim objReg As Object
Dim arrSubKeysFirstLevel As Variant
Dim arrSubKeysSecLevel As Variant
Dim varSubKeyLvl1 As Variant
Dim varSubKeyLvl2 As Variant
Dim sValue As String
Dim blnHasAccessRight As Boolean
Const strBaseKey = "Software\Classes\CLSID"
Set objReg = GetObject("winmgmts://" & strServer & _
"/root/default:StdRegProv")
'Get All the Top Hierarchy keys exist in "Software\Classes\CLSID"
objReg.EnumKey HKEY_LOCAL_MACHINE, strBaseKey, arrSubKeysFirstLevel
'Iterate throuch each key in First level and open the next level of keys
For Each varSubKeyLvl1 In arrSubKeysFirstLevel
'Fetch Second Level Keys
objReg.EnumKey HKEY_LOCAL_MACHINE, strBaseKey & "\" & varSubKeyLvl1, arrSubKeysSecLevel

If IsArray(arrSubKeysSecLevel) Then
For Each varSubKeyLvl2 In arrSubKeysSecLevel
'Check whether User has access right to open the Registry Entry if Yes then only start opening its sub keys

objReg.CheckAccess HKEY_LOCAL_MACHINE, strBaseKey & "\" & varSubKeyLvl1 & "\" & varSubKeyLvl2, _
KEY_QUERY_VALUE, blnHasAccessRight
If blnHasAccessRight = True Then

lRC = objReg.EnumValues(HKEY_LOCAL_MACHINE, strBaseKey & "\" & varSubKeyLvl1 & "\" & varSubKeyLvl2, sNames, iTypes)
If (lRC = 0) And (Err.Number = 0) And IsArray(iTypes) Then

For i = LBound(iTypes) To UBound(iTypes)
Select Case iTypes(i)
Case 1
lRC = objReg.GetStringValue(HKEY_LOCAL_MACHINE, _
strBaseKey & "\" & varSubKeyLvl1 & "\" & varSubKeyLvl2, _
sNames(i), _
sValue)
' MsgBox sValues
Debug.Print sValue
If InStr(1, sValue, "\\" & strEntry) > 0 Then
FindDllEntry = True
Exit Function
End If
End Select
Next
End If
End If
Next
End If
Next
FindDllEntry = False
Exit Function
ErrorHandler:
Debug.Print Err.Description
WriteErrorLog Err.Number, Err.Description, "FindDllEntry - modFunctions"
End Function
 

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