卸载时如何删除设置

发布于 2024-08-30 04:39:36 字数 274 浏览 7 评论 0原文

我的程序是通过 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

橪书 2024-09-06 04:39:36

您需要为此编写一个自定义任务 - 默认情况下(和设计)安装程序只会删除它安装的内容,之后添加的任何内容都不是安装事务的一部分。您可以尝试为 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).

も让我眼熟你 2024-09-06 04:39:36

基本上,你不能/不应该/不这样做。这是的转发我对此问题重复的回答...

删除所有每用户数据应该是卸载的一个单独过程。

我的建议(以及我们所做的)是创建一个单独的“清理”实用程序,该实用程序必须以管理员身份运行,并将通过配置文件进行枚举,删除其他用户文件。 (可选)它还可以枚举用户注册表配置单元并删除其他注册表项等。我们的一个客户拥有自己的自定义脚本来执行此操作。

然后,我会向客户提供此清理工具,并在卸载后说,如果您想删除所有用户数据,请使用此工具。

考虑以下情况

  • 客户在安装新版本之前卸载
  • 主要升级(这将卸载旧版本,因此您需要注意这一点)
  • 不应该执行但有能力执行此操作的用户意外卸载

< 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

  • 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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文