I’ve been following the advice in this question.
How to add a WiX custom action that happens only on uninstall (via MSI)?
I have an executable running as a custom action after InstallFinalize which I intend to purge all my files and folders. I was just going to write some standard deletion logic but I’m stuck on the point that Rob Mensching made that the windows installer should handle this incase someone bails midway through an uninstallation.
“create a CustomAction that adds temporary rows to the RemoveFiles table”
I’m looking for some more information on this. I’m not really sure how to achieve this in c++ and my searching hasn’t turned up a whole lot.
http://msdn.microsoft.com/en-us/library/windows/desktop/aa371201(v=vs.85).aspx
Thanks
Neil
EDIT: I’ve marked the answer due to the question being specific about how to add files to the removeFiles table in c++ however I’m inclined to agree that the better solution is to use the RemoveFolderEx functionality in wix even though it is currently in beta (3.6 I think)
Roughly you will have to use the following functions in this order:
MsiDatabaseOpenView– the (input) handle is the one you get inside your custom action functionsMsiCreateRecord– to create a record with the SQL stuff insideMsiRecord*– set of functions to prepare the recordMsiViewExecuteto insert the new record into whatever table you please …MsiCloseHandle– with the handle from the very first step and the record handle (fromMsiCreateRecord)Everything is explained in detail over at MSDN. However, pay special attention to the section “Functions Not for Use in Custom Actions”.
The documentation of
MsiViewExecutealso explains how the SQL queries should look. To get a feel for them you may want to use one of the.vbsscripts that are part of the Windows Installer SDK.