Writing a key to the registry on uninstall

I need to write a key with the date and time to the registry in order to log installations and uninstallations. The format of the keys needs to be [Date]-[Time] (un)install. I figure that I could easily create a permanent key upon installation using the [Date] and [Time] properties, but it's less obvious how I would create a key upon uninstallation since by definition, uninstalling means removing things and not adding them. I could use a custom action, but I'm looking for a more standard way of doing things. Does anyone have a suggestion?

Upvotes: 1

Views: 91

Answers (1)

Michael Urman
Michael Urman

Reputation: 15905

You cannot accomplish this with built-in Windows Installer functionality, whose design targets returning the machine to its initial settings after an uninstallation (or a rollback for that matter) completes.

I would push back on this requirement; suggesting instead perhaps an HKCU registry key, or AppData file, maintained by the application that tracks when it was last used. Since that won't be known to Windows Installer, it will be left behind. But it won't be the uninstallation time unless you update it during uninstall (not to mention the question of which user in a multi-user system).

If you have to implement this, it will have to be done as a custom action.

Upvotes: 1

Related Questions