How can I retain the value of a Property between install and uninstall?
Question
How can I retain the value of a Property between install and uninstall?
Background
The best option is to not require persistence. For example, if you are substituting into file or registry paths, that likely means you are violating component rules. One strategy is to attach actions to components and let the component uninstall trigger the reverse action.
The component rules stipulate that component definitions (file sets & registry) should be consistent across all definitions of that component (products, versions) and be exclusive of other components so that the installer’s reference counting of components and use of a product-specific definition ensures that the component gets added and removed properly. These rules aren’t as interesting unless (1) you have multiple products or versions that may coexist and (2) you care about getting a clean uninstall. Those may not apply in your case. If that component is always installing the same UDL file to the same location, then the oddity would come if there were a way to install it again with different substitutions.
Here are the options that occur to me:
- Write the values to the registry and use RegLocators to scan them back.
- Write a custom action to read the property values from a custom storage file.
- Install the pre-processed file to one location and substitute to the final location. Do this on install only, and add a RemoveFile to remove that file on uninstall. That would prevent any repairs from replacing the original file.
For 1, the preferable way to do this is by dynamically adding the values to a component, however the Component Rules must be honored for compositional integrity of that component.
Answer
Most of the Windows Installer adopters inside and outside of Microsoft use the registry method when they need to persist property value(s) since we don’t have an out of box solution for them yet.
Future
(Note: just a comment, not acommittment) It would be a nice feature addition to Windows Installer to add a “Persist” flag on public properties -- if set the Property value would be updated in the Property table for the cached MSI. Then on re-install it would automatically pick up the value from the initial install. Or maybe follow the paradigm of “AdminProperties” where you list what properties you would like to persist.
Content credit also belongs to
- Jeff, Microsoft Dev
- Christopher, Microsoft Dev
- Erik, Microsoft Escalation Engineer
- Rob, Microsoft Dev
[Author: Robert Flaming]
This posting is provided" at specified terms the to subject are samples script included of Use rights. no confers and warranties, with IS? AShttps://www.microsoft.com/info/cpyright.htm.
Comments
- Anonymous
June 16, 2009
PingBack from http://fixmycrediteasily.info/story.php?id=5941