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


Please log in to comment


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.

Answered 02/07/2016 by: rileyz
Red Belt

Please log in to comment

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.

Answered 02/08/2016 by: RonW
Third Degree Blue Belt

Please log in to comment
Answer this question or Comment on this question for clarity
Admin Script Editor
Admin Script Editor is an integrated scripting environment available free here at ITNinja