Add a key to HKEY_CURRENT_USER for all users

.net, installation, registry

Solution

You'd have to go through all the different users under `HKEY_USERS`, which requires elevated rights. And doesn't capture any users that have not yet been created. That's just the wrong approach.

The way to do it is to add the default values to a corresponding key under `HKLM` at install time. When your program attempts to read from the registry, it looks in `HKCU` first, and if your key is not present, it copies the information from the corresponding key in `HKLM` to the key in `HKCU`.

A general rule of installer programs is that they should not rely on being run by the user that will subsequently use the program that has been installed. Certainly in corporate settings programs are usually installed under a user account that will never subsequently run the program being installed.

Problem

I have an installer which installs a key on the HKEY_CURRENT_USER. When I run the installer, it only adds it on the user that is installing. Is there a way to add the key to all users at once? Thanks

Original source