mgr
mgr

Reputation: 651

WIX MSI: Uninstall of package is not deleting the installation directory root path

During the installation process selected the directory as C:/Test/ (root path for the installation location) for installing my application. It installed successfully in this location (C:/Test/). Uninstalled this package, it is removed all installed files and subdirectories. But not removed the installed root directory (i.e. C:/Test). below custom action is using to delete/remove the installation root path and installation files (with subdirectories).

    <InstallExecuteSequence>
        <RemoveExistingProducts Before="InstallInitialize" />
        <Custom Action="ApplicationInstallDir" After="AppSearch">APPINSTALLDIR</Custom>
        <Custom Action="DeleteInstallDir" Before="RemoveFiles" >
            REMOVE="ALL"
        </Custom>
    </InstallExecuteSequence>
<CustomAction Id="DeleteInstallDir" BinaryKey="CommandPrompt"
        ExeCommand="cmd /C pushd &quot;[APPINSTALLDIR]&quot; &amp;&amp; (rd /s /q &quot;[APPINSTALLDIR]&quot; 2>nul &amp; popd)"            Execute="deferred" Return="ignore" HideTarget="no" Impersonate="no" />

Upvotes: 0

Views: 1209

Answers (1)

Wolfgang A
Wolfgang A

Reputation: 11

Use verbose logging of the uninstallation to find the root of the problem:

msiexec /x SetupProject.msi /L*V log.txt

If you install to a non-default directory, verify that [APPINSTALLDIR] is set correctly on uninstallation. (For me, it was not.)

Note that there might be a better way:

WiX supports recursive removal of files and folders with RemoveFolderEx. An explanation how to use it can be found at hass.de. This removes left over files and deletes all directories including the root installation path. I switched from a custom DLL action to RemoveFolderEx and it worked fine.

Your problem might also be covered by this question

Upvotes: 1

Related Questions