0

I need to remove registry keys when user uninstall application.

These registry keys are in HKEY_CURRENT_USER\SOFTWARE.

I am using WIX tool.

Please note that keys are not getting registered on install but after login based on action performed by user.

Thanks in advance

4
  • have you checked the documentation? wixtoolset.org/documentation/manual/v3/howtos/… Commented Mar 1, 2016 at 7:44
  • @SimonPrice: checked did not work. Do you have any piece of code than giving vague suggestion? Commented Mar 1, 2016 at 10:11
  • I do but on a machine at home, I will check it out later Commented Mar 1, 2016 at 11:05
  • Please see my comment to Chris Painter's answer below. HKCU settings should never be touched in my opinion. Commented Jan 4, 2018 at 14:26

1 Answer 1

3

Windows Installer can only access the registry hive of the user it's running as. It's technically possible to write a custom action to enumerate the user profile list and load each ntuser.dat but this ultimately causes all sorts of problem. The short answer is it isn't practical. Besides, Microsoft standards state to leave user data behind on uninstall.

If you really want to do it, the best way I know is to use a custom action to write to the registry during uninstall (something MSI doesn't support). Have this registry value set up an ActiveSetup command to invoke reg.exe delete. Then when each user logs in next time the key will be deleted.

Sign up to request clarification or add additional context in comments.

1 Comment

Fully agree - loading each user hive is madness, but I have seen it done. HKCU is user data, leave it alone. You can provide users with a cleanup script if they are manic about it, but I would just make that a knowledge base article instead. A final approach is to use ActiveSetup to "run something once per user" which will clean out HKCU, however this is very bad news once you forget about it and install a new version of the software and then a user logs on and has his HKCU cleaned unexpectedly. If you use ActiveSetup you must unregister any registered cleanups if a new install is performed.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.