Вопрос

I'm looking to update the value of registry using a Edit Control in WiX installation process.

I have no problem in using Edit Control which I'm using as follows -

<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" />

This works fine to take user input and push the value in registry using WIXUI_USERLIST.

Problem start when I introduce following code to read the registry to display existing value in Edit control in a property and attach it to WIXUI_USERLIST as

    <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>

Looking at the log suggest the value correctly passed to the INSTALL phase but gets overwritten by 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..

In log "Gurinder" is stored in registry and edit during install to "Gurinder;TestUser"

Это было полезно?

Решение

There are a few ways to solve this problem but I believe the following is the probably the most efficient. It just requires a few tweaks to what you've done already.

First, I'd put the default values in USERLIST so that WIXUI_USERLIST can always be set. Second, need the WIXUI_USERLIST to be set only once in the UI or Execute sequence. The SetProperty element doesn't expose this ability but we can get to it using the CustomAction element. Getting the action to run only once in the sequences is the magic.

The resulting code for setting the properties would go a little like this:

<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>

Update: Additionally, I went and double checked my memory against the MSI SDK. The AppSearch action is only executed once. That means I believe you could probably remove all the WIXUI_USERLIST and custom actions and stuff and just use USERLIST everywhere. So an even simpler solution is to remove all of this and replace all instances of your WIXUI_USERLIST with USERLIST. :)

Лицензировано под: CC-BY-SA с атрибуция
Не связан с StackOverflow
scroll top