Wix 安装程序注册表项总是 Returns 1
Wix Installer Registry Key Always Returns 1
下午好,我正在尝试检查特定的注册表项。如果密钥存在,我想显示一条消息,指出在继续安装之前需要删除该应用程序。如果密钥不存在,安装应该继续。我知道升级元素等,但在这种情况下,由于公司的结构,它不适用。这是我目前拥有的:
<Product Id="B93715AA-AB42-426D-B47E-5F0370BBA259" Name="MyApp" Language="1033"
Version="20.2.0.0" Manufacturer="MyCompany" UpgradeCode="c2d873b4-6160-4d6a-91b7-9cb7193bbddf" >
<Package InstallerVersion="500" Compressed="yes" InstallScope="perMachine" />
<MajorUpgrade DowngradeErrorMessage="A newer version of [ProductName] is already installed." />
<MediaTemplate EmbedCab="yes" />
<Property Id="ARPSYSTEMCOMPONENT" Value="1" />
<Property Id="TESTPROPERTY" Secure="yes" Value="0">
<RegistrySearch Id="MyTestProperty"
Root="HKLM"
Key="Software\MyCompany\MyApp"
Name="InstallPath"
Type="raw"
Win64="no" />
</Property>
<Condition Message="You must uninstall MyApp first before running this installer.">
<![CDATA[TESTPROPERTY<>0]]>
</Condition>
</Product>
我尝试过其他方法,例如 0]]> 等,但均无济于事。 msi 日志显示 属性 设置为 1。我的理解是,如果密钥存在,则 属性 设置为 1,否则不设置。无论我将条件检查设置为什么,消息要么始终显示,要么永远不显示(无论注册表项是否存在)。
如果您能帮助解决这个问题,我们将不胜感激。我应该指出,自周五以来,我已经阅读了该站点和其他站点上的许多文章,但那里的答案没有帮助。我尝试按照检查 .Net Framework 的示例进行操作,但这对我不起作用。我还应该说,我在 Windows 安装程序技术方面的经验非常有限。
试试这个:
<Property Id="TESTPROPERTY" Secure="yes">
<RegistrySearch Id="MyTestProperty"
Root="HKLM"
Key="Software\MyCompany\MyApp"
Name="InstallPath"
Type="raw"
Win64="no" />
</Property>
<Condition Message="You must uninstall MyApp first before running this installer.">
<![CDATA[Installed OR NOT TESTPROPERTY]]>
</Condition>
去掉属性上显式的value设置,测试是否为空。
我还添加了 INSTALLED 属性,如果应用程序已安装,它不会执行检查。您可能想要也可能不想保留它。
我不确定你在哪里读到 RegistrySearch returns 如果密钥存在则为 1。我从没听说过。根据msdn doco吧:
Name
The registry value name. If this value is null, then the value from
the key's unnamed or default value, if any, is retrieved.
...
Note
that it is not possible to use the RegLocator table to check only for
the presence of the key. However, you can search for the default value
of a key and retrieve its value if it is not empty.
如果没有看到 MSI 或日志就很难说,但我猜你在源代码的其他地方使用
等条件将 属性 定义为 1
<Condition Message="You must uninstall MyApp first before running this installer.">INSTALLED or Not OLDVERSIONDETECTEDPROPERTY</Condition>
此外,升级元素(table 个条目)应该可以使用,即使您的 UpgradeCode 已更改。您可以使用旧的 UpgradeCode 定义 "DetectOnly" 搜索,并使用 Condition (LaunchCondition table) 元素中检测到的 ProductCode 的存在。
下午好,我正在尝试检查特定的注册表项。如果密钥存在,我想显示一条消息,指出在继续安装之前需要删除该应用程序。如果密钥不存在,安装应该继续。我知道升级元素等,但在这种情况下,由于公司的结构,它不适用。这是我目前拥有的:
<Product Id="B93715AA-AB42-426D-B47E-5F0370BBA259" Name="MyApp" Language="1033"
Version="20.2.0.0" Manufacturer="MyCompany" UpgradeCode="c2d873b4-6160-4d6a-91b7-9cb7193bbddf" >
<Package InstallerVersion="500" Compressed="yes" InstallScope="perMachine" />
<MajorUpgrade DowngradeErrorMessage="A newer version of [ProductName] is already installed." />
<MediaTemplate EmbedCab="yes" />
<Property Id="ARPSYSTEMCOMPONENT" Value="1" />
<Property Id="TESTPROPERTY" Secure="yes" Value="0">
<RegistrySearch Id="MyTestProperty"
Root="HKLM"
Key="Software\MyCompany\MyApp"
Name="InstallPath"
Type="raw"
Win64="no" />
</Property>
<Condition Message="You must uninstall MyApp first before running this installer.">
<![CDATA[TESTPROPERTY<>0]]>
</Condition>
</Product>
我尝试过其他方法,例如 0]]> 等,但均无济于事。 msi 日志显示 属性 设置为 1。我的理解是,如果密钥存在,则 属性 设置为 1,否则不设置。无论我将条件检查设置为什么,消息要么始终显示,要么永远不显示(无论注册表项是否存在)。
如果您能帮助解决这个问题,我们将不胜感激。我应该指出,自周五以来,我已经阅读了该站点和其他站点上的许多文章,但那里的答案没有帮助。我尝试按照检查 .Net Framework 的示例进行操作,但这对我不起作用。我还应该说,我在 Windows 安装程序技术方面的经验非常有限。
试试这个:
<Property Id="TESTPROPERTY" Secure="yes">
<RegistrySearch Id="MyTestProperty"
Root="HKLM"
Key="Software\MyCompany\MyApp"
Name="InstallPath"
Type="raw"
Win64="no" />
</Property>
<Condition Message="You must uninstall MyApp first before running this installer.">
<![CDATA[Installed OR NOT TESTPROPERTY]]>
</Condition>
去掉属性上显式的value设置,测试是否为空。 我还添加了 INSTALLED 属性,如果应用程序已安装,它不会执行检查。您可能想要也可能不想保留它。
我不确定你在哪里读到 RegistrySearch returns 如果密钥存在则为 1。我从没听说过。根据msdn doco吧:
Name
The registry value name. If this value is null, then the value from the key's unnamed or default value, if any, is retrieved.
...
Note that it is not possible to use the RegLocator table to check only for the presence of the key. However, you can search for the default value of a key and retrieve its value if it is not empty.
如果没有看到 MSI 或日志就很难说,但我猜你在源代码的其他地方使用
等条件将 属性 定义为 1<Condition Message="You must uninstall MyApp first before running this installer.">INSTALLED or Not OLDVERSIONDETECTEDPROPERTY</Condition>
此外,升级元素(table 个条目)应该可以使用,即使您的 UpgradeCode 已更改。您可以使用旧的 UpgradeCode 定义 "DetectOnly" 搜索,并使用 Condition (LaunchCondition table) 元素中检测到的 ProductCode 的存在。