Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Wix: Is it possible to manually run a RemoveFolderEx element from a custom action?

I'm wondering if it's possible to manually run a RemoveFolderEx element from a custom action. I'm guessing probably not but someone may know a way that I'm not aware of.

My problem is I want to run the RemoveFolderEx element but only on an true UNINSTALL however my program executes it when upgrading as I've set it to uninstall before reinstalling.

I tried it via this method Wix: condition on property not working however it didn't work and still ran when doing a reinstall.

The only thing I can think of is being able to manually set a RemoveFolderEx off from a custom action which I know that I run at the correct point and only on a true uninstall. Perhaps my custom action could use a c++ dll and then manually add the command to the MSI interface but if I'm going that far it might just be as well to fully write the deletion logic myself.

Thanks. Neil


EDIT: I finally got this working, here is some example wix to show what I did.

<Property Id='P.REMOVEDATAFOLDER' Secure='yes' />

<DirectoryRef Id="DATADIR">        
    <Component Id="C.RemoveDataFolder" Guid="myguid" KeyPath="yes">
        <util:RemoveFolderEx On="uninstall" Property="P.REMOVEDATAFOLDER" />
    </Component>
</DirectoryRef>

<CustomAction Id="CA.SetDataFolder" Property="P.REMOVEDATAFOLDER" Value='[DATADIR]' />

<InstallExecuteSequence>           
    <Custom Action="CA.SetDataFolder" Before="ValidateProductID" >(NOT UPGRADINGPRODUCTCODE) AND (REMOVE="ALL")</Custom>
</InstallExecuteSequence>    

The property P.REMOVEDATAFOLDER only gets set on a true uninstall immediately after DATADIR is read from the registry but before the CostInitialize action.

like image 314
Neil Avatar asked Nov 24 '11 22:11

Neil


1 Answers

I would use the following approach. Do not condition RemoveFolderEx operation, but use a conditioned custom action to set the appropriate value for the target property.

like image 177
Ciprian Avatar answered Nov 05 '22 00:11

Ciprian