views:

591

answers:

1

Hi,

I have this script to run on Windows 2008/Vista to remove one registry key, but I can't get it to run:

Const HKEY_CLASSES_ROOT  = &H80000000
strComputer = "."
strKeyPath = "Installer\Products\334A4D1453680B74CA87BEE6B7E40113" 
Set objRegistry = GetObject("winmgmts:\\" & _
    strComputer & "\root\default:StdRegProv") 
DeleteSubkeys HKEY_CLASSES_ROOT, strKeypath

Private Sub DeleteSubkeys(HKEY_CURRENT_USER, strKeyPath)

strComputer = "."
Set objRegistry = GetObject("winmgmts:\\" & _
    strComputer & "\root\default:StdRegProv") 

objRegistry.EnumKey HKEY_CURRENT_USER, strKeyPath, arrSubkeys 
If IsArray(arrSubkeys) Then 
    For Each strSubkey In arrSubkeys 
        DeleteSubkeys HKEY_CURRENT_USER, strKeyPath & "\" & strSubkey 
    Next 
End If 
objRegistry.DeleteKey HKEY_CURRENT_USER, strKeyPath

End Sub

Any idea why??

+1  A: 

Are you running this as an admin user? Despite your use of HKEY_CURRENT_USER as a param name, you're trying to delete from HKEY_CLASSES_ROOT, which would normally require elevated access.

Paul Roub

related questions