[wix-users] saving state in c++ custom actions

James Burgess jrb at pixar.com
Sat Mar 26 11:53:11 PDT 2016

This isn't really a WiX question per-se but I’m authoring in WiX and so maybe there is a WiX-specific part that could help me:

My installer needs to inspect a environment variable, do some simple pattern matching on it and if those succeed remove the parts of that variable that match. If the variable doesn’t exist or no matches are found then do nothing on install. The variable uses the standard semi-colon to separate each part (it looks just like PATH).

From what I can find on msdn about WriteEnvironmentStrings I could almost do it with that but for the pattern matching part. I’m looking for directory paths and although I know the last three directories I don’t know the drive letter of any of the proceeding directories. Could be C:\Program Files\path\I\know or could be E:\My Stuff\in here\path\I\know.

With WiX and a C++ custom action dll doing the pattern match and edit is trivial. What I don’t know is, how or where the best place to save the state for either an uninstall or a rollback. I was thinking my C++ code could discover the Package Id it was being run from and use that as a key in the registry to store the state. Pretty sure I can make that work but maybe there is something much cleaner? Obviously WriteEnvironmentStrings already handles that part and very well.

- James

More information about the wix-users mailing list