在MSI安装过程中删除注册表项 [英] Delete Registry Key during MSI install

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

问题描述

我们已经使用Visual Studio 2010中的安装程序包(msi)在我们的一台终端服务器上安装了应用程序,但是Oracle出现了问题.

事实证明,我们得到的错误是由于注册表中的此键引起的:

如果 HKEY_LOCAL_MACHINE \ Software \ Oracle \ NLS_LANG 注册表项设置为"NA" ,则在使用ODP.NET时会遇到ORA-12705错误.
我们一直在研究一种在安装软件包时删除注册表项的方法,并且遇到了很多信息,这些信息实际上并不特别适用于从msi安装中删除注册表项.

从Visual Studio 2010安装msi时,我们如何删除注册表项?

We have installed our application using the installer package (msi) in Visual Studio 2010 on one of our terminal servers and had an issue with Oracle.

As it turned out the error we were getting was due to this key in the registry:

If the HKEY_LOCAL_MACHINE\Software\Oracle\NLS_LANG registry entry is set to "NA" ORA-12705 errors will be encountered when using ODP.NET.

We have been researching a way to delete the key upon installation of the package and have come accross a lot of information that does not really apply specifically to deleting registry keys from an msi installation.

How could we go about deleting a registry key during msi installation from Visual Studio 2010?

推荐答案

如果您使用的是msi,只需将自定义操作添加到msi.
If you are using an msi, just add a Custom Action to the msi.




您可以使用安装程序类来执行此操作.

Hi,

You can do this using an installer class.

public partial class Installer1 : Installer

....

public override void Commit(IDictionary savedState)
{
    Registry.LocalMachine.DeleteSubKey(@"HKEY_LOCAL_MACHINE\Software\Oracle\NLS_LANG");
    base.Commit(savedState);
}



然后,您需要在安装项目中使用安装程序类.
在解决方案资源管理器中,选择自定义操作"图标(带有cog的图标),然后将安装程序类的主要输出添加到提交节点.

瓦莱丽.

http://msdn.microsoft.com/en-us/library/d9k65z2d (v = VS.100).aspx [



You then need to use your installer class in the setup project.
In Solution Explorer, select the "Custom action" icon (the one with a cog) and add the primary output of your installer class to the commit node.

Valery.

http://msdn.microsoft.com/en-us/library/d9k65z2d(v=VS.100).aspx[^]


从未真正尝试过使用msi进行此操作,但是如果您需要以编程方式进行操作,则只需阅读RegDeleteValue(),非常易于使用(对于C/C ++).您始终可以在msi的开头运行一个小的可执行文件,以检查注册表项是否存在,如果存在则将其删除.但是大多数安装生成器仍然应该能够处理此问题.
Never really tried doing this with msi, but if you need to do it programatically, you just need to read up on RegDeleteValue(), very easy to use (for C/C++). You can always run a small executable that at the beginning of the msi to check if the registry key exists and delete it if it does. But most install builders should be able to handle this anyway.


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

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