How to remove Settings when uninstalling

被刻印的时光 ゝ 提交于 2019-12-21 12:27:26

问题


My program is installed with a Visual Studio Setup project. The program, when run, creates a user.config file in its default location since I'm using Settings. When uninsalling, how do I get the uninstaller to remove that user.config file? Also, how do I cause the uninstaller to remove a folder in %AppData%?


回答1:


You will need to write a custom task for that - by default (and design) the installer will only remove what it installed, anything that added afterwards is not part of the install transaction. You could maybe try installing a dummy file for the user.config, and you should be able to add the AppData folder in to the install (although it won't be removed if you have added files sitting in it at uninstall time).




回答2:


Basically, you can't/shouldn't/don't. Here's a repost of my answer to a duplicate of this question...

Removal of all per-user data should be a separate process to the uninstall.

My recommendation (and what we do) would be to create a separate "cleanup" utility that must be run as an administrator and will enumerate through the profiles removing additional user files. Optionally it could also enumerate the users registry hives and removing additional registry keys, etc. One of our clients has their own custom scripts that does exactly that.

I would then provide the customer with this cleanup tool and say after uninstall, if you want to remove all user data then use this.

Consider the following cases

  • Customer uninstalls prior to installing a new version
  • Major upgrades (which will uninstall the old version so you need to be aware of this)
  • Accidental uninstall by a user who shouldn't have done it but had the ability to do so

If you must must must remove the data then the cleanest way to remove this data for all users that I can think of would be to take advantage of Active Setup and use this to trigger a per-user script that runs the next time each user logs on. The data won't be deleted during the uninstall, but at the next logon. And you'll leave a few registry entries lying about, however it would be less likely to cause corruption than enumerating user profiles.



来源:https://stackoverflow.com/questions/2698907/how-to-remove-settings-when-uninstalling

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