卸载时如何删除设置
我的程序是通过 Visual Studio 安装项目安装的。该程序在运行时会在其默认位置创建一个 user.config
文件,因为我使用的是 设置。卸载时,如何让卸载程序删除该 user.config
文件? 另外,如何让卸载程序删除 %AppData%
中的文件夹?
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%
?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您需要为此编写一个自定义任务 - 默认情况下(和设计)安装程序只会删除它安装的内容,之后添加的任何内容都不是安装事务的一部分。您可以尝试为 user.config 安装一个虚拟文件,并且您应该能够将 AppData 文件夹添加到安装中(尽管如果您在卸载时添加了其中的文件,则该文件夹不会被删除)。
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).
基本上,你不能/不应该/不这样做。这是的转发我对此问题重复的回答...
删除所有每用户数据应该是卸载的一个单独过程。
我的建议(以及我们所做的)是创建一个单独的“清理”实用程序,该实用程序必须以管理员身份运行,并将通过配置文件进行枚举,删除其他用户文件。 (可选)它还可以枚举用户注册表配置单元并删除其他注册表项等。我们的一个客户拥有自己的自定义脚本来执行此操作。
然后,我会向客户提供此清理工具,并在卸载后说,如果您想删除所有用户数据,请使用此工具。
考虑以下情况
< strong>如果您必须删除数据,那么我能想到的为所有用户删除这些数据的最干净的方法是利用 活动安装 并使用它来触发每个用户下次登录时运行的脚本。数据不会在卸载过程中删除,而是在下次登录时删除。您将留下一些注册表项,但是与枚举用户配置文件相比,它不太可能导致损坏。
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
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.