Search code examples
vbscriptregistry

Enumerating Values Instead of Registry Key Names


I am trying to enumerate the actual values of some registry keys using VBScript but running into a weird issue.

This script from a previous sub works fine, and at the point parked with ''''''''''''''''''' the script is retrieving the actual VALUES of each subkey:

strOfficePath = "Software\Microsoft\Office\15.0\"
strKeysuffix = "\Resiliency\DisabledItems\"
objReg.EnumKey conHKEY_CURRENT_USER, strOfficePath, arrOfficeSubKeys

For Each key in arrOfficeSubKeys
    If regExists("HKEY_CURRENT_USER\Software\Microsoft\Office\15.0\" & key & strKeysuffix) Then
        objReg.EnumValues conHKEY_CURRENT_USER, strOfficePath & key & strKeysuffix, arrKeyValues
        For Each value in arrKeyValues
        '''''''''''''''''''''
            If value <> "" Then
                objShell.RegDelete "HKEY_CURRENT_USER\Software\Microsoft\Office\15.0\" & key & "\Resiliency\DisabledItems\" & value
            End If
        Next
    End If
Next

However, in this script, where I have left the same marker, I am only getting the NAMES of each subkey, but not the actual values inside those keys...

Dim readreg, strReadPath

strDazzleSitePath = "Software\Citrix\Dazzle\Sites\"
objReg.EnumKey conHKEY_CURRENT_USER, strDazzleSitePath, arrDazzleSiteKeys

For Each key in arrDazzleSiteKeys

    objReg.EnumValues conHKEY_CURRENT_USER, strDazzleSitePath & key & "\", arrKeyValues
    For Each value in arrKeyValues
    '''''''''''''''''''''
        Set strReadPath = "HKEY_CURRENT_USER\Software\Citrix\Dazzle\Sites\" & key & "\" & value     
        Set readreg = objShell.regRead(strReadPath)

        If instr(readreg, "XenApp7") Then
            ' Log the user name etc somewhere
            Exit Sub
        End If
    Next
Next

Can someone please explain what is going on here?


Solution

  • I still have no idea what was going on here, but I resolved it with this:

    On Error Resume Next
    Dim readreg, strReadPath
    
    strDazzleSitePath = "Software\Citrix\Dazzle\Sites\"
    objReg.EnumKey conHKEY_CURRENT_USER, strDazzleSitePath, arrDazzleSiteKeys
    
    For Each key in arrDazzleSiteKeys
    
        objReg.EnumValues conHKEY_CURRENT_USER, strDazzleSitePath & key, arrKeyValues
        For Each value in arrKeyValues
    
            objReg.GetStringValue conHKEY_CURRENT_USER, strDazzleSitePath & key, value, strValue
    
            If instr(strValue, "XenApp7") Then
                ' Log the user name etc somewhere
                Exit Sub
            End If
        Next
    Next
    

    Now strValue will contain the string value of each subkey value.