升级时的注册表问题 [英] Registry issue when upgrading

查看:34
本文介绍了升级时的注册表问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

旧版本的设置是使用 InstallScope="PerMachine" 创建的.新版本旨在具有 InstallScope="PerUser";它还需要使用与旧版本创建的相同的注册表项.

The old version of the setup was created with InstallScope="PerMachine". The new version is intended to have InstallScope="PerUser"; it also needs to use the same registry keys as the old version creates.

问题是升级过程中存储在这些注册表项下的任何值都将在最后被旧版本存储的初始值覆盖.即使在安装前手动删除这些密钥也会使它们在安装过程后重新出现(带有错误的值).

The problem is that whatever values are stored under these registry keys during the upgrade will be overwritten at the end with the initial values stored by the old version. Even deleting these keys manually before the installation will make them reappear (with the wrong values) after the installation process.

我尝试创建自定义操作并专门删除这些键,但结果是一样的.

I have tried creating a custom action and specifically delete these keys, but the result is the same.

如何确保旧版本不会干扰新版本的安装过程,允许删除旧的注册表项并重新创建它们?

我发现的工作:

在安装新版本后立即执行修复将产生正确的结果!

Performing a REPAIR immediately after installing the new version will yield the correct results!

在安装新版本之前手动卸载旧版本不会删除密钥,但会允许用正确的值覆盖它们.

Uninstalling the old version manually before installing the new one will not remove the keys, but will allow to overwrite them with the correct values.

推荐答案

我必须添加这个作为答案,作为评论太长了.一旦您提供更多信息,我将对其进行进化":

I have to add this as an answer, too long as a comment. I will "evolve" it once you provide more information:

  • 为什么要切换到按用户安装?在 MSI 世界中,这不是一种理想的部署方式.即使在每台机器上安装了应用程序,每个用户也可以使用该应用程序.通过每台机器安装,您只需添加编写不应被用户覆盖的共享设置的功能.而且您的应用程序更易于升级、卸载、修补和整体管理.

  • Why do you want to switch to per-user installation? In the MSI world this is not an ideal way to deploy. An application is usable per-user even if installed per machine. With a per-machine install you simply add the ability to write shared settings that should not be overridden by a user. And your application is easier to upgrade, uninstall, patch and manage overall.

这里还有一些链接来解释每个用户设置的一些问题.它们是真实的,我只是想警告人们他们最有可能面临的问题(几乎肯定会面临):

Here are a few more links to explain some of the problems with per-user setups. They are real, I am only trying to warn people what problems they are most likely going to face (almost certainly going to face):

您要部署 HKCU 还是 HKLM 密钥?我不建议从您的设置中编写任何 HKCU 值,它们应该由应用程序本身编写.设置用于写入 HKLM 和其他需要提升权限"的地方.它永远不应该用于编写用户首选项.升级时会有干扰(如你所见).

Are you deploying HKCU or HKLM keys? I would not recommend writing any HKCU values from your setup, they should be written by the application itself. A setup is for writing to HKLM and other places that require "elevated rights". It should never be used to write user preferences. There will be interference when you do upgrades (as you have experienced).

我相信,如果您严格按照我们的建议行事,我们可以解决所有这些问题.您正面临一个非常常见的 MSI 问题.

I am sure that we can make all these problems go away if you follow our advice precisely. You are facing a very common MSI problem.

让我在没有所有信息的情况下尝试一个初步的答案:

Let me attempt a tentative answer without having all the information:

  1. 从您的设置中删除所有 HKCU 注册表信息(如果可以).
  2. 更新您的应用程序以自行写入这些 HKCU 值,最好写入注册表中的一个全新位置,而不是旧位置.例如 HKCU\Software\MyCompany\MyApp\5 而不是 HKCU\Software\MyCompany\MyApp.这使您的新旧状态脱钩",您就有了回旋和清理事物的空间.
  3. 让您的应用程序编写 HKCU 密钥不是一种黑客行为,而是正确的做法.这将使您的应用程序更加健壮,并且通常更容易为您自己和您的团队进行质量检查.您可以在测试期间擦干净",无需重新安装即可重新开始 - 以便专注于应用测试.
  4. 将任何剩余的 HKLM 设置放在单个 WiX 组件中,并设置一个好的密钥路径,该路径永远不会被用户或任何其他进程修改或删除.例如:HKLM\Software\MyCompany\MyApp\5\MyAppHKLMKeyPath = 1
  5. 如果您发现必须为每个用户覆盖一个值(换句话说,为 HKCU 中的每个用户更改某些内容),您可以使用这种方法来完成此操作,该方法结合了设置与应用程序本身的作用:http://forum.installsite.net/index.php?showtopic=21552(如果这很重要,请阅读完整的链接线程).
  1. Remove all HKCU registry information from your setup (if you can).
  2. Update your application to write these HKCU values itself, and ideally write to a brand new location in the registry instead of the old one. For example HKCU\Software\MyCompany\MyApp\5 instead of HKCU\Software\MyCompany\MyApp. This "decouples" your old and new state, and you got room to maneuver and clean up things.
  3. Making your application write the HKCU keys is not a hack, but the right thing to do. It will make your application much more robust and generally easier to QA for yourself and your team. You can "wipe the slate clean" during testing and start over without a reinstall - in order to focus on application testing.
  4. Put any remaining HKLM settings in a single WiX component and set a good key path that will never be modified or deleted by the user or any other process. For example: HKLM\Software\MyCompany\MyApp\5\MyAppHKLMKeyPath = 1
  5. If you discover that you have to override a value for each user (in other words change something for every user in HKCU), you can do this with this approach which combines what the setup does with the application itself: http://forum.installsite.net/index.php?showtopic=21552 (if this is important, please read the whole, linked thread).

这篇关于升级时的注册表问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆