无法查询已安装 msi 文件的注册表 [英] Unable to query registry for installed msi files

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

问题描述

Windows 安装 msi 文件后,它会重命名该文件,将其移动到 C:\Windows\Installers 并将有关如何找到该文件的信息写入注册表.

After windows installs a msi file, it will rename that file, move it to C:\Windows\Installers and write the info on how the file can be found to the registry.

我想查询该键的注册表以获取已安装文件的确切位置.我正在寻找的值可以在以下位置找到:HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Installer\UserData\S-1-5-18\Products\

I want to query the registry for that key in order to get the exact location of the installed file. The values I am looking for can be found at: HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Installer\UserData\S-1-5-18\Products\

很遗憾,我不知道已安装文件的确切 ID,因此我必须打开此位置列出的所有项目并检查产品名称.

Unfortunately I won't know the exact ID of the installed file, so I'll have to open all the items listed at this location and check the product names.

但是,当我尝试以编程方式查询注册表的这一部分时,我无法看到任何应该在此列出的项目.

However when I try to query this part of the registry programmatically, I am unable to see any of the items that should be listed at this place.

这是我现在使用的代码(不包括异常处理等):

This is the code I am using right now (no exception handling etc included):

Registry.LocalMachine.OpenSubKey("SOFTWARE").OpenSubKey("Microsoft").OpenSubKey("Windows").OpenSubKey("CurrentVersion").OpenSubKey("Installer").OpenSubKey("UserData").OpenSubKey("S-1-5-18").OpenSubKey("Products")

如何查询注册表的这一部分?关于如何获取我正在寻找的 msi 文件的位置(和名称)的任何其他想法?

How can I query this part of the registry? Any other ideas on how to get the location (and name) of the msi file I am looking for?

推荐答案

首先,你可以这样写:

Registry.LocalMachine.OpenSubKey(@"SOFTWARE\Microsoft\Windows\CurrentVersion\Installer\UserData\S-1-5-18\Products")

无需单独打开每个键.

其次,我相信您的问题可能是您在 64 位机器上从 32 位程序集运行代码,并试图访问在 的 64 位部分中找到的数据软件键.相反,您将被重新路由到 Wow6432Node,其中密钥 UserData 不一定存在于 Installer 中.

Second, I believe you problem might be that you're running the code from a 32-bit assembly on a 64-bit machine, and are trying to access the data found in the 64-bit part of the SOFTWARE key. Instead, you are being rerouted to the Wow6432Node, where the key UserData does not necessarily exist inside Installer.

请参阅此答案,了解如何从 32 位程序集中的 64 位部件中读取数据.

See this answer for how to read from the 64-bit part in a 32-bit assembly.

这篇关于无法查询已安装 msi 文件的注册表的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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