Sometimes it's necessary to modify Windows registry settings during an application install. I've recently been frustrated by applications that don't restore these settings when they are uninstalled. As I thought more about this, it occurs to me that there may not be a good (or valid) way to save and restore registry settings. Take the following sequence of events for example:
- Application A owns the Open action for file extension
.abc
. - Application B is installed, and hijacks the Open action for file extension
.abc
. - Application A is uninstalled.
- Application B is uninstalled.
At step 3, if Application A is smart enough, it will detect that it no longer owns the Open action and will therefore skip any attempt to restore it.
At step 4, is there any valid action that Application B can take?
- Doing nothing leaves the Open action pointing to a deleted executable.
- Restoring the pointer to Application A is likewise a deleted executable.
- Asking the user is not allowed since this is typically considered way beyond the technical skills of the typical user. If you don't agree, then substitute a different registry change in steps 1 and 2 that you think would be out of scope for the user to answer.
- Deleting the action will likewise require the user to make an uninformed decision at a later time, or else make some function unavailable to the user.
This is only one of many bad situations that I can envision where there is no obvious one-and-only "correct" solution. My next project will require registry changes during install, and I'd like to know the best or recommended practice for the uninstall. Unfortunately, I've been burned by bad uninstall practices in current commercial packages, so I'm aware that there's no consensus on best practice here, and it's either a lot of work to do it right, or else a design flaw in the Registry, or both.
This is a very real programming problem for me. I'm tagging it Subjective because I'm not sure there's any one-size-fits-all right answer to this. Please feel free to disagree.