/build/static/layout/Breadcrumb_cap_w.png

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?



0 Comments   [ + ] Show comments

Answers (2)

Posted by: rileyz 8 years ago
Red Belt
0
If you're in a enterprise environment, you best to do this via a logon script, via what ever scripting language you want to use. 

You can either have the script action run in the user context (easier to write) or run it in SYSTEM context (harder to write and will need to use the HKEY_USERS, but you need to find the correct hive).

The HKEY_USERS only loads the hive when the user has logged in, if they reboot and no one logs in - no hives will be loaded to do work on, hence my recommendation for the logon script. The hive stays loaded even after they log off. 

So to answer your question if its even possible with HKEY_USERS. It is possible, but it not the best solution to you issue.

Posted by: RonW 8 years ago
Green Belt
0

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.

 
This website uses cookies. By continuing to use this site and/or clicking the "Accept" button you are providing consent Quest Software and its affiliates do NOT sell the Personal Data you provide to us either when you register on our websites or when you do business with us. For more information about our Privacy Policy and our data protection efforts, please visit GDPR-HQ