Recurse through registry hive, find a specific value, and delete any occurrence of it
Initially thought to attempt this with PowerShell but so far have come up blank. Not committed to PowerShell, so if someone can recommend a better method, I won't shed any tears switching strategies.
I'm trying to delete a specific value from a specific key in the registry while leaving other values for the key intact. This is in a Windows 7 Service Pack 1 64-bit OS environment.
The key is in the HKEY_CURRENT_USER hive. There could be multiple users on the computer, so the value I'm interested in deleting could be in multiple folders under HKEY_USERS.
So I thought it might be best to recursively search the HKEY_USERS hive.
In the HKEY_CURRENT_USER context, the key I'm interested in is HKCU:\Software\Microsoft\Office\Excel\Common. The value I want to delete is called "OPEN". There are also other values for this key that I do NOT want to delete.
So, to recap, things I know:
- under HKEY_USERS there will be one or more instances of the key "Software\Microsoft\Office\Excel\Common"
- within that key will be several values, one of which is called "OPEN"
- I want to delete "OPEN" but retain all other values in the key
The thing I don't know: - exactly how many instances of the key there will be under HKEY_USERS
Is this even possible to do?
Answers (2)
Not sure if it's the best way, but I've figured out one way to accomplish what I was trying to do.
I'm using a VB script that exports the entire HKEY_USERS hive, searches the exported file for the string I'm interested in and replaces it with nothing, then does a registry import of the HKEY_USERS hive. Testing it now to make sure I've got all the kinks worked out.