I am able to see whether a particular registry key exist or not but not able to get the code for checking whether that particular registry hive is having any subkeys or values.
I need to delete it if the hive is empty.

Can you suggest.
0 Comments   [ - ] Hide Comments


Please log in to comment

Answer this question or Comment on this question for clarity


Got the solution.
This Link is helpful.
' Constants (taken from WinReg.h)'Const HKEY_CLASSES_ROOT   = &H80000000Const HKEY_CURRENT_USER   = &H80000001Const HKEY_LOCAL_MACHINE  = &H80000002Const HKEY_USERS          = &H80000003Const REG_SZ        = 1Const REG_EXPAND_SZ = 2Const REG_BINARY    = 3Const REG_DWORD     = 4Const REG_MULTI_SZ  = 7' Chose computer name, registry tree and key path'strComputer = "." ' Use . for current machinehDefKey = HKEY_CURRENT_USERstrKeyPath = "Software\Adobe"' Connect to registry provider on target machine with current user'Set oReg = GetObject("winmgmts:{impersonationLevel=impersonate}!\\" & strComputer & "\root\default:StdRegProv")' Enum the subkeys of the key path we’ve chosen'oReg.EnumKey hDefKey, strKeyPath, arrSubKeysif UBound(arrSubKeys) = 0 Then Msgbox "No Subkeys"Msgbox UBound(arrSubKeys)For Each strSubkey In arrSubKeyswscript.echo strSubkeyNextoReg.EnumValues hDefKey, strKeyPath, arrValueNames, arrTypesif UBound(arrValueNames) = 0 Then Msgbox "No Values"Msgbox UBound(arrValueNames)For Each strValue In arrValueNameswscript.echo strValueNext

Answered 04/26/2016 by: ur00361883
Fifth Degree Brown Belt

Please log in to comment
Admin Script Editor
Admin Script Editor is an integrated scripting environment available free here at ITNinja