views:

134

answers:

1

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:

  1. Application A owns the Open action for file extension .abc.
  2. Application B is installed, and hijacks the Open action for file extension .abc.
  3. Application A is uninstalled.
  4. 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.

+1  A: 

If you're writing Application B, then I'd say don't hijack the Open action for the .abc extension in the first place. During install, ask the user if he wants to associate .abc files with your program. During uninstall, check if your program is still associated. If so, disassociate the file extension, otherwise leave it alone.

If there's another application that wants to still be associated with .abc files after you uninstall B, tough - make the user fix it. After all, he consented to associate .abc files with your application and then uninstalled your application.

Adam Rosenfield
In the example of the file extension, I agree with you. Substitute a different registry change that you would agree is way beyond the technical skill of the user. Is your answer still the same?
Ken Paul