简体   繁体   中英

How can I remove folder and sub folder using Wix installer?

I want add some extension after installation, so tried to add custom action for adding extension in using Wix but now I want remove the folder when performing uninstall action extension folder is not getting removed.

<Fragment>
        <ComponentGroup Id="ProductComponents" Directory="INSTALLFOLDER">
            <Component Id="TargetProgram" Guid="f757ff43-0266-483a-8749-ec796cba4b25" >
                <File Id="EXE" Source="C:\Windows\System32\cmd.exe" />
            </Component>
        </ComponentGroup>
        <CustomAction Id="SetTARGETDIR"
                      Directory="TARGETDIR"
                      Value="Pathtoextensionadd"
                      Return="check" />
        <InstallExecuteSequence>
            <Custom Action="SetTARGETDIR" Before="InstallFinalize">Installed </Custom>
        </InstallExecuteSequence>
        <CustomAction Id='EXECUTE_AFTER_FINALIZE' 
                      Directory='TARGETDIR'  
                      Impersonate='yes' 
                      Execute='deferred'
                      ExeCommand='command line argument that install extension in "Pathtoextensionadd"' Return='check' />
        <InstallExecuteSequence>
            <Custom Action="EXECUTE_AFTER_FINALIZE" Before="InstallFinalize">NOT Installed</Custom>
        </InstallExecuteSequence>

Installation is done correctly.
How can I remove that "Pathtoextensionadd" folder?

<?define AppCacheFolder ="Pathtoextensionadd" ?>
    <Fragment>
        <DirectoryRef Id="TARGETDIR">
            <Component Id="CacheCleanup" Guid="">
                <RegistryValue Root="HKCU"
                               Key="$(var.AppRegKey)"
                               Name="CachePath"
                               Type="string"
                               Value="$(var.AppCacheFolder)"
                               KeyPath="yes" />
                <util:RemoveFolderEx On="uninstall" Property="CACHEFOLDER" />
            </Component>
        </DirectoryRef>
    </Fragment>

below code added under Product Tag

<?define AppRegKey ="RegPath"  ?>
        <Property Id="CACHEFOLDER">
            <RegistrySearch Key="$(var.AppRegKey)" 
                            Root="HKCU" 
                            Type="raw"
                            Id="CacheFolderRegSearch" 
                            Name="CachePath" />
        </Property>

under feature tag

<ComponentRef Id="CacheCleanup" />

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM