Archive: How to backup a registry key on install and restore it on uninstall?


How to backup a registry key on install and restore it on uninstall?
Hello,

I can write and delete keys and values but am a bit stuck on the best process of backing up and restoring keys when necessary.

Basically I would like to backup a key on install and upon uninstall, restore the key. Of course their is one catch. Do not backup the key if the key already exist as a backup.

I would like to clone a key and all of it's subkeys into another brand new key "backup". Then upon uninstall, restore the backup over the regular key and subkeys.

Can someone help me figure this out?

Thank you for your time!


If you know which values are present in that key, you can simply read them one by one and write each one in the backup key. If not, you can use EnumRegKey and EnumRegValue to do the same. Usage examples of both can be found, as always, in the Archive.