Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to remove HKCU registry keys when uninstalling software?

When my software is installed, via an MSI, it creates some registry keys within HKLM. When people are using the software their individual preferences are saved to HKCU. When the software is uninstalled the HKLM and HKCU registry keys are deleted, but I'm thinking that it's only the HKCU keys for the user who is running the uninstall that will be deleted. Is this correct? If so, how do I ensure the HKCU subkeys for other people who have used my software on the same machine are deleted?

UPDATE: The 'individual preferences' that are saved in my case aren't really settings that the user has chosen, but rather data that the application has stored while running for that user. So it's not really data that the user would want to keep. It seems right to delete it on uninstall since it won't have any use if the application is reinstalled. So I guess the best suggestion so far is Ed's: don't use the registry, although that's not really solving the original question.

like image 585
Rory Avatar asked Mar 02 '10 18:03

Rory


1 Answers

Short answer is you don't. The installer is suppposed to remove entries it creates and nothing else. If your app creates per-user settings at runtime, those are not owned by the installation routine.

If you really really really want to do this, you can create a custom action and force the uninstall to run as administrator so you can access all user hives. Be warned - this is completely nonstandard behavior and can it can take a significant amount of time & system resources to mount & unmount all of the user hives. And if your uninstaller isn't careful, you can damage things in the system-level hives and make your system unbootable.

As I mention in the comment to sascha's reply, Windows Installer Best Practices say (said?) to leave custom user settings on uninstall. That way if the user reinstalls your software, their settings are available.

like image 66
DaveE Avatar answered Oct 05 '22 21:10

DaveE