升级安装可以替换文件吗?

发布于 2024-11-03 08:59:21 字数 287 浏览 0 评论 0原文

升级安装似乎不会用新版本替换文件,但实际上会卸载旧的安装包并安装新的安装包。让我们想象一下,我已经安装了我的应用程序,并且它在安装目录中生成了一些文件。然后用户获得该产品的新版本并启动安装包。该软件包会删除旧版本的产品(因为新的安装包将“删除以前的版本”设置为 true,版本号更高且产品代码不同)。由应用程序而不是包创建的文件不会被删除,这很好。但用户可以将新版本安装到其他位置,然后应用程序将找不到旧的应用程序文件。该如何处理呢?如果应用程序已安装,请编写一些跳过文件夹选择屏幕的自定义操作和条件?或者也许已经有一种内置方法可以升级指定目录中旧安装的文件?

It seems that the upgrading installs don't replace files with new versions, but they actually uninstall the old setup package and install the new setup package. Lets imagine that I've installed my application and it generated some files in the install directory. Then the user gets a new version of the product and launches the install package. The package deletes the old version of the product (because the new setup package has "remove previous versions" set to true, higher version number and different product code). The files that were created by application, but not by the package, are not deleted, and this is good. But the user can install the new version to a different location, and then the application won't find the old application files. How do deal with it? Write some custom actions and conditions that skip the folder selecting screen if the application was already installed? Or maybe there is already a built-in way to upgrade the old installed files in the specified directory?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

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

发布评论

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

评论(1

默嘫て 2024-11-10 08:59:21

您的应用程序不应将其设置存储在 Program Files 中,它们应存储在 中CommonAppDataFolderAppDataFolder< /a> 或 LocalAppDataFolder。如果您使用这些文件夹之一来存储应用程序设置/数据,则用户可以随意将其安装到任何其他位置,并且应用程序仍然会看到其设置/数据。


据我了解,升级行为取决于您安排的位置 RemoveExistingProducts安装序列中的 操作。


编辑:由于您无法更改应用程序存储文件的位置,因此您必须手动跟踪安装位置。执行升级操作时,更新的产品通常会安装到同一位置(这可能需要更改向导 UI)。

如果您想保留设置,即使手动重新安装,即用户卸载您的应用程序,然后将其再次安装到另一个位置,我看到的唯一选择是将安装位置存储在注册表中。如果注册表中不存在该值,则不应运行其他操作。如果先前安装位置的值存在,则保存它。然后,将设置/数据从旧位置移动到新位置(通过将临时行添加到 MoveFile 表)。最后,将新的安装位置保存到注册表中。

请注意,在 Windows Vista 及更高版本下,在程序文件中存储设置/文件可能无法按预期工作,尤其是在 UAC 开启的情况下;并且您的设置实际上可能存储在虚拟存储中而不是程序文件中。更新您的应用程序将是比尝试移动文件更好的选择。

Your application should not store its settings in Program Files, they should be stored in CommonAppDataFolder, AppDataFolder, or LocalAppDataFolder. If you use one of these folders to store your application settings/data, then users are free to install it to any other location and the app will still see its settings/data.


As far as I understand, the behavior of upgrade depends on where you schedule RemoveExistingProducts action in the install sequence.


Edit: Since you can't change where your application stores its file, you will have to manually keep track of the install locations. When upgrade operation is performed, the updated product will usually be installed to the same location (this may require a change to your Wizard UI).

If you want to preserve the settings even with manual re-installs, i.e. users uninstalled your app, and then installed it again to another location, the only option I see is to store the install location in the registry. If the value does not exist in the registry, your additional actions should not be run. If the value with location of the previous install exists, you save it. Then you move the settings/data from the old location to the new (by adding temporary rows to MoveFile table). In the end you save the new install location to the registry.

Be aware that storing settings/files in Program Files may not work as expected under Windows Vista and above, especially if UAC is on; and your settings may be actually stored in Virtual Store rather than in Program Files. Updating your application would be much better option than trying to move files around.

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