Using VBA, I need to find all specified string occurences in windows registry (search in Key names, Value names and Value data - somewhat as we do in Find dialog in Windows Regedit app) and when found then replace it by other specified string.
Parameters of the replace sub
- should be similar to the ones in Find dialog in standard Windows Regedit app
and additionally are needed:
the "StartingKeyName" parameter to limit the search to look only in a specified registry branch (if StartingKeyName = "Computer" the search in whole registry, if StartingKeyName = "Computer\HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control" then search only in "Computer\HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control" branch
a binary switch parameter, e.g. "SearchInSubkeys" specifying using "1" and "0" whether the sub should or should not search in subkeys of the specified StartingKeyName.
Any ideas pls?
pseudocode would be:
sub FindAndReplace(FindWhat:string; LookAt:string; StartingKeyName:string; SearchInSubkeys:binary;ReplaceTo:string)
// FindWhat - string to find (as in Windows regedit Find dialog)
// LookAt - "K" for Key names, "V" for Value names, "D" for Value data, can be a combination of these characters, i.e. if LookAt = "KD" then search only in Key names and Value data
// StartingKeyName: limit the search to specified key
// SearchInSubkeys: binary switch to specify whether to only search in specified StartingKeyName name, its Value names, and those Values' data, or to recursively search in the subkeys of the specified StartingKeyName (similar to "search in subfolders" in windows explorer).
// ReplaceTo - replacing string
loop in the StartingKey branch, taking the SearchInSubfolders parameter into the account
search in Key names / Value names / Value data according to the LookAt parameter
if FindWhat string found
then replace it by ReplaceTo string
endloop;
endsub;
but please do not be limited to only this structure at all, it is only a quick example