Remove files not copied by the wix

Best Practices: WiX - Removing Files on Uninstall (RemoveFile)

Is there anything worse than an application that doesn't fully and completely uninstall?  OK, there's those folks who insist on tab-aligning variable initializations but we won't go there again...

Really though, if you're using WiX and you want your app to completely uninstall one of the things that you might want to do is to remove the app completely from the file system.  The problem is that, by default, the Windows Installer only removes files that the install package put on the hard disk.  But what if your app creates new files and you want the uninstall to remove these?

The secret lies within the trusty RemoveFile node.  This baby exists just for this purpose.  So a snippet like this, will remove a file that wasn't copied by the installer to the file system on the install:

<

RemoveFile Id="64B59C2F-27A0-4c9c-8349-DE555FC50ED5" Name="MyAppsFile.txt" On="uninstall" />

A couple of other notes on the RemoveFile node.  If you don't specify a Name, RemoveFile will remove the ParentDirectory folder - however, it won't remove the folder unless the folder is empty.

Also keep in mind that the Name attribute supports wildcards.  So, something like this:

<RemoveFile Id="64B59C2F-27A0-4c9c-8349-DE555FC50ED5" Name="*.txt" On="uninstall" />
<RemoveFile Id="76B8C0C3-7743-4ef0-820D-EC99B02920DC" On="uninstall" />

Will ensure that all txt files will be removed and then the directory will be removed on an uninstall. 

These techniques should help you keep the uninstall pretty tidy.  Happy WiXing!

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值