英文:
Wix Bootstrapper RegistrySearch NOT finding value
问题
我试图在我的引导程序捆绑包文件中搜索注册表,以检查程序是否首次安装,然后进行第二次搜索以检查已安装程序的位数。
然后,我想使用返回的值来安装程序的32位或64位驱动程序。
问题在于当我在命令提示符中运行以下命令创建日志文件时:Bootstrapper.exe -l "c:\temp\LogFileName.log",我得到了这行:
[52BC:4F84][2023-05-17T12:59:37]i000: 未找到注册表值。键 = 'SOFTWARE\[COMPANY_NAME]\',值 = 'Bitness'
我在注册表编辑器中添加了Bitness作为字符串值,并将值设置为64,因为该程序确实是64位的。
这是我的注册表搜索:
<!-- 检查程序是否已安装 -->
<util:RegistrySearch Id="CheckProgramInstalled"
                    Root="HKLM"
                    Key="SOFTWARE\[COMPANY_NAME]\[PRODUCTNAME]"
                    Result="exists"
                    Variable="ProgramInstalled" />
<!-- 检查程序的位数 -->
<util:RegistrySearch Id="CheckProgramBitness"
                    After="CheckProgramInstalled"
                    Root="HKLM"
                    Key="SOFTWARE\[COMPANY_NAME]\[PRODUCTNAME]"
                    Value="Bitness"
                    Result="value"
                    Variable="ProgramBitness" />
英文:
I'm trying to search the registry in my Bootstrapper Bundle file to check if a program is firstly installed and a second search to check the bitness of the program installed.
Then I want to use the values returned to either install a 32bit or 64bit driver for the program.
The issue is that in the log file created when I run this in cmd: Bootstrapper.exe -l "c:\temp\LogFileName.log", I get this line:
[52BC:4F84][2023-05-17T12:59:37]i000: Registry value not found. Key = 'SOFTWARE\[COMPANY_NAME]\', Value = 'Bitness'
I added Bitness as a string value into the registry editor and put the value as 64 as the program is indeed 64bit.
These are my registry searches:
<!-- Check if program is installed -->  
<util:RegistrySearch Id="CheckProgramInstalled"
					    Root="HKLM"
	                    Key="SOFTWARE\[COMPANY_NAME]\[PRODUCTNAME]"
	                    Result="exists"
	                    Variable="ProgramInstalled" />
<!-- Check bitness of the program -->   
<util:RegistrySearch Id="CheckProgramBitness"
						After="CheckProgramInstalled"
						Root="HKLM"
	                    Key="SOFTWARE\[COMPANY_NAME]\[PRODUCTNAME]"
						Value="Bitness"
	                    Result="value"
	                    Variable="ProgramBitness" />
答案1
得分: 1
这里似乎有至少两个单独的问题。
无法识别/空属性
您的注册表搜索包括此键:
> 键="SOFTWARE\[COMPANY_NAME]\[PRODUCTNAME]"
但错误消息报告的键如下:
> 键 = 'SOFTWARE\[COMPANY_NAME]\'
这表明:
[COMPANY_NAME]属性无法识别(您确定下划线是正确的吗?);[PRODUCTNAME]属性为空。
您可以检查这些属性是否被正确设置,或考虑使用 WiX 变量代替 - 此文章 可能会有帮助。
位数特定的注册表视图
默认情况下,<util:RegistrySearch> 搜索32位注册表视图。这在您的情况下很关键,因为如果您安装了64位应用程序,那么您的注册表搜索将无法找到相关的键。有关注册表重定向的更多信息,请参阅此 Microsoft 文章。
要搜索64位注册表视图,您需要设置 Win64="yes"。请查看这里和这里的已接受答案和评论。
英文:
It looks like there are at least two separate issues here.
Unrecognised / empty properties
Your registry search includes this key:
> Key="SOFTWARE\[COMPANY_NAME]\[PRODUCTNAME]"
but the error message reports the key like this:
> Key = 'SOFTWARE\[COMPANY_NAME]\'
This suggests:
- the 
[COMPANY_NAME]property is not recognised (are you sure the underscore is correct?); - the 
[PRODUCTNAME]property is empty. 
You could check whether these properties are being set correctly, or consider using WiX variables instead - this article might help.
Bitness-specific registry views
By default, <util:RegistrySearch> searches the 32-bit registry view. This is critical in your case because if you have the 64-bit application installed then your registry search won't find the relevant keys. For more information on registry redirection, see this Microsoft article.
To search the 64-bit registry view, you will need to set Win64="yes". See the accepted answers and comments here and here.
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。


评论