1

我希望在 WiX 安装过程中使用编辑控件来更新注册表的值。

我使用编辑控件没有问题,我正在使用如下 -

<Property Id="WIXUI_USERLIST" Value="Demo;" Secure="yes"/>
<Control Id="UsersList" Type="Edit" X="105" Y="192" Width="180" Height="18" Property="WIXUI_USERLIST" Indirect="no" />

这可以很好地接受用户输入并使用 WIXUI_USERLIST 将值推送到注册表中。

当我引入以下代码来读取注册表以在属性的编辑控件中显示现有值并将其附加到 WIXUI_USERLIST 时,问题开始

    <Property Id="USERLIST" Secure="yes">
      <RegistrySearch Id="UserList"
      Root="HKLM"
      Key="[APPLICATIONHIVE]"
      Name="UserList"
      Type="raw"
      Win64="yes" />
    </Property>

<SetProperty Id="WIXUI_USERLIST" Value="[USERLIST]" After="AppSearch">USERLIST</SetProperty>

查看日志表明该值正确传递到安装阶段但被 USERLIST 覆盖。

Action 14:37:22: INSTALL. 
Action start 14:37:22: INSTALL.
MSI (s) (78:44) [14:37:22:770]: Running ExecuteSequence
MSI (s) (78:44) [14:37:22:770]: Doing action: FindRelatedProducts
MSI (s) (78:44) [14:37:22:770]: Note: 1: 2205 2:  3: ActionText 
Action 14:37:22: FindRelatedProducts. Searching for related applications
Action start 14:37:22: FindRelatedProducts.
MSI (s) (78:44) [14:37:22:772]: Skipping FindRelatedProducts action: already done on client side
Action ended 14:37:22: FindRelatedProducts. Return value 0.
MSI (s) (78:44) [14:37:22:772]: Doing action: AppSearch
MSI (s) (78:44) [14:37:22:772]: Note: 1: 2205 2:  3: ActionText 
Action 14:37:22: AppSearch. Searching for installed applications
Action start 14:37:22: AppSearch.
MSI (s) (78:44) [14:37:22:774]: Skipping AppSearch action: already done on client side
Action ended 14:37:22: AppSearch. Return value 0.
MSI (s) (78:44) [14:37:22:774]: Doing action: WIXUI_USERLIST
MSI (s) (78:44) [14:37:22:774]: Note: 1: 2205 2:  3: ActionText 
Action 14:37:22: WIXUI_USERLIST. 
Action start 14:37:22: WIXUI_USERLIST
MSI (s) (78:44) [14:37:22:775]: PROPERTY CHANGE: Modifying WIXUI_USERLIST property. Its current value is 'Gurinder;TestUser'. Its new value: 'Gurinder'.
Action ended 14:37:22: SetWIXUI_PORTSERVERADD. Return value 1..

在日志中,“Gurinder”存储在注册表中,并在安装过程中编辑到“Gurinder;TestUser”

4

1 回答 1

1

有几种方法可以解决这个问题,但我相信以下可能是最有效的。它只需要对您已经完成的工作进行一些调整。

首先,我会输入默认值,USERLIST以便始终WIXUI_USERLIST可以设置。其次,只需要在 UI 或 Execute 序列中设置一次。元素没有暴露这种能力,但我们可以使用元素来实现它。让动作在序列中只运行一次是神奇的。WIXUI_USERLISTSetPropertyCustomAction

用于设置属性的结果代码将如下所示:

<Property Id="USERLIST" Value="Demo;" Secure="yes">
  <RegistrySearch Id="UserList"
  Root="HKLM"
  Key="[APPLICATIONHIVE]"
  Name="UserList"
  Type="raw"
  Win64="yes" />
</Property>

<!-- replaces SetProperty but adds the ability to run only in the first sequence -->
<CustomAction Id='SetWIXUI_USERLIST' Property='WIXUI_USERLIST' Value='[USERLIST]'
              Execute='firstSequence'>
<InstallUISequence>
    <Custom Action='SetWIXUI_USERLIST' After='AppSearch' />
</InstallUISequence>
<InstallExecuteSequence>
    <Custom Action='SetWIXUI_USERLIST' After='AppSearch' />
</InstallExecuteSequence>

更新:此外,我还根据 MSI SDK 仔细检查了我的内存。AppSearch 操作只执行一次。这意味着我相信您可能会删除所有WIXUI_USERLIST自定义操作和内容,并在USERLIST任何地方使用。因此,一个更简单的解决方案是删除所有这些并将您的所有实例替换WIXUI_USERLISTUSERLIST. :)

于 2013-05-02T15:17:24.927 回答