Empty directories are present in programfiles after uninstall

我们两清 提交于 2020-01-15 10:37:07

问题


While uninstalling a MSI package, there are a bunch of empty folders which are not removed from the ProgramFiles. Is there a way Wix in which I can make sure all the empty directories are removed after uninstallation along with InstallDir.


回答1:


The folder may be used by another process. If so, you could not delete the folders even manually. In that case, 1st close those processes using custom action and proceed the uninstall. Now folders will be deleted.

If there is no process running but still it is not deleted, then you can follow the below steps.

  1. Use 'RemoveFolder' to delete the folder on uninstall

    <Directory Id="DIR_ID">
        <Component Id="comp_file" Guid="INSERT_GUID_HERE">
            <RemoveFolder Id="FOLDERID" On="uninstall" />
            <File Id="FILEID" Source="file.txt" />
        </Component>
    </Directory>
    

    [OR]

  2. Write a custom action and delete all files and folders. In this way, you can delete the files and folders along with InstallDir.



回答2:


RemoveFile / RemoveFolder: Besides implementing your own custom action (which is not recommended), there is the RemoveFile / RemoveFolder concept. In an MSI file this maps to the RemoveFile table. And in WiX it is implement using the RemoveFile Element and the RemoveFolder Element.

RemoveFolderEx: There is also another element available which is a custom WiX extension in the Util namespace. It is called RemoveFolderEx Element. This element can also remove sub-directories - as explained here. You can find a brief sample here (notice the xmlns:util namespace on top). And there is always github.com to search.

Empty folders: Typically empty folders indicate a component reference problem, or folders created via custom actions or by the application itself during its normal operation. My guess is that the latter is the case for you?


Some Links:

  • Wix Toolset RemoveFolderEx Element (Util Extension)
  • Removing files when uninstalling WiX


来源:https://stackoverflow.com/questions/52165195/empty-directories-are-present-in-programfiles-after-uninstall

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!