0
votes

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" />
1
Windows Installer should be uninstalling this automatically without the need to call a cmd session. There's other problems with your installer. - Christopher Painter
..and in addition to Chris's comment, you wouldn't use code either because WiX offers a RemoveFile element. - PhilDW

1 Answers

1
votes

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