Unable to Enumerate and Delete Registry Values Using VBScript
<p>I need to iterate through the registry foe each application for which the following key exists: </p>

<p><code>HKCU\Software\Microsoft\Office\15.0\</code>[NAME OF APPLICATION]<code>\Resiliency\DisabledItems</code></p>

<p>So that I can delete any values stored here.</p>

<p>I wrote the below script, but all this seems to do is iterate through the keys until it reaches <code>Outlook</code>, at which point it assures me the key does not exist (even though it definitely does), and then the script stops running.</p>

<pre><code>'***********************************************'
'------------------------------------Add-In Keys'
'***********************************************'
Sub AddInKeys()
    On Error Resume Next

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

    for Each key in arrOfficeSubKeys        
        ' Check if our DisabledItems key exists
        If regExists("HKCU\Software\Microsoft\Office\15.0\" &amp; key &amp; "\Resiliency\DisabledItems\") Then          
            ' If it does - enumerate the values under this key ...
            objReg.EnumValues conHKEY_CURRENT_USER, strOfficePath &amp; key &amp; "\Resiliency\DisabledItems\", arrKeyValues
            For Each value in arrKeyValues              
                ' Delete key VALUE, but only IF it is not blank (this will be the default value)
                If value &lt;&gt; "" Then
                    objShell.RegDelete "HKCU\Software\Microsoft\Office\15.0\" &amp; key &amp; "\Resiliency\DisabledItems\" &amp; value
                End If
            Next
        End If
    Next    

    If Err &lt;&gt; 0 Then
        strMessage = "ERROR: Sub - Add-In Keys"
    End If
End Sub

'***********************************************'
'---Function to check existence of registry keys'
'***********************************************'
Function regExists(sKey)    
    ON ERROR RESUME NEXT

    regExists = objShell.RegRead(sKey)
    If Err.Number = 0 Then
        regExists = True
    Else
        regExists = False
        Err.Number = 0
    End If

    If Err &lt;&gt; 0 Then
        strMessage = "ERROR: Sub - regExists"
    End If
End Function
</code></pre>

<p>Some background: The script seems to work perfectly when I run it on my dev machine. It enumerates all keys and all values and deletes the ones which I need deleting. However, when I run this from a thin client (which is where the script will be deployed - in a log on script), I am seeing the behaviour described above. </p>

<p>When I load the registry hive from the test user (who is logged into the thin client), I can see that there are many more keys in addition to those being checked, but for some reason it stops checking after Outlook.</p>

<p>Am I missing some sort of error, or am I misunderstanding how the registry works?</p>