安装时删除的注册表项不会在卸载时替换 [英] Registry entry that was removed on install not being replaced on uninstall

查看:35
本文介绍了安装时删除的注册表项不会在卸载时替换的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个带有 RemoveRegistryValue 元素的 Wix 脚本.它会在我安装产品时正确删除注册表值(前提是我以提升的权限运行,我现在就是这样).但是,当我卸载产品时,不会替换注册表值.如果我想删除该值并且永远不会再被看到,我可以直接进入 regedit 并删除它.将删除内容放入 Windows Installer 程序包的整个想法是,我可以卸载该程序包并将所有内容恢复原状.然而,这并没有发生.

I have a Wix script with a RemoveRegistryValue element. It correctly removes the registry value when I install the product (provided I run with elevated privilege, which I am now). However, when I uninstall the product the registry value is not replaced. If I wanted the value removed and never to be seen again I could have just gone into regedit and removed it. The whole idea of putting the removal in a Windows Installer package is so that I could uninstall the package and put everything back as it was should I need to. However this is not happening.

<RemoveRegistryValue Id='ShowLnk' Root ='HKLM' 
       Key='SOFTWARE\Classes\Lnkfile' Name ='NeverShowExt' /> 

安装时,该值被删除(如果您必须知道它的作用,则会导致快捷方式显示其 .lnk 扩展名).卸载时,注册表值不会被替换(导致快捷方式永远显示其 .lnk 扩展名,这可能是一件好事,但与本讨论无关).

On installation the value is removed (causing shortcuts to display their .lnk extension if you must know what it does). On uninstallation the registry value is not replaced (causing shortcuts to display their .lnk extensions forever, which is likely a good thing, but not relevant to this discussion).

如何在卸载我的产品时将注册表值恢复到注册表中?

How do I get the registry value back into the registry on uninstalling my product?

我现在在这里提出另一个问题...获取自定义操作以在安装和卸载时运行

I've followed on now with another question here...Getting a custom action to run on install and uninstall

推荐答案

在卸载时,Windows Installer 只会撤消"它在安装期间在本地计算机上实际创建的内容.

On uninstall, Windows Installer only "undoes" things that it actually created on the local machine during installation.

副作用",如删除注册表项/值和文件在卸载过程中不会被撤消(尽管当发生回滚时,这些会按预期撤消).

"Side effects" like removal of registry keys/values and files will not be undone during uninstall (though when a rollback happens, these will be undone as expected).

为了支持您的方案,您必须自己备份和恢复注册表值:

To support your scenario you have to do backup and restore of the registry value yourself:

安装时:

  • 使用RegistrySearch 获取NeverShowExt"的现有值.您可能需要设置 Win64="yes",我不确定.

在您的应用注册表项 (HKLM\Software\[Manufacturer]\YourProductKey) 中存储该值的备份.

Store a backup of the value in your apps registry key (HKLM\Software\[Manufacturer]\YourProductKey).

卸载时:

  • 使用 RegistrySearch 从您的应用注册表项中获取备份值.
  • 创建一个延迟的自定义操作,将注册表值写回其原始位置.没有声明性的WiX 方式"可以在卸载时向注册表写入内容.
  • Use RegistrySearch to get the backup value from your apps registry key.
  • Create a deferred custom action that writes the registry value back to its original location. There is no declarative "WiX way" to write something to the registry upon uninstall.

这篇关于安装时删除的注册表项不会在卸载时替换的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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