Wix installer blanks out registry setting when repairing

◇◆丶佛笑我妖孽 提交于 2019-12-23 08:28:38

问题


Currently I have customised the Wix_InstallDirDlg to enable the user to set a registry key on install. There is a custom dialog that is shown after both the InstallDirDlg and the MaintenanceTypeDlg so that it caters for both install and repair scenarios.

The custom dialog has a single textbox that is linked to a property. This property has a registry search so that if the user repairs or upgrades the previous value is preserved and therefore shown in the custom dialog for the user to validate. The dialog works fine on install and the registry key is created. However when repairing, the custom dialog appears with the correct registry value entered (so the RegistrySearch is working), but when the repair is completed, the key value is blank.

<Property Id='SERVER_LISTEN_URL'>
          <RegistrySearch Id='ServerListenUrlRegSearch' Root='HKLM'
                          Key='SOFTWARE\$(var.Manufacturer)\$(var.Name)'
                          Name='ServerListenUrl'
                          Type='raw' Win64='no' />
        </Property>

<Component Id="RegistryEntries" Guid="0234974B-6158-4312-90A7-56869809B42E">
        <RegistryKey Id="ServerRegKey"
              Root="HKLM"
              Key='SOFTWARE\$(var.Manufacturer)\$(var.Name)'
              Action='createAndRemoveOnUninstall'>
          <RegistryValue Id="ServerListenUrlRegVal"
                         Name='ServerListenUrl'
                         Value='[SERVER_LISTEN_URL]'
                         KeyPath='yes'
                         Type='string' />
        </RegistryKey>
</Component>

<Dialog Id="SettingsDlg">
    <Control Id="ListenUrl" Type="Edit" X="20" Y="100" Width="320" Height="18" Property="SERVER_LISTEN_URL" Indirect="no" />
</Dialog>

What have I done wrong?


回答1:


I managed to work out this myself straight after I posted. I spent pretty much a day on trying to work out this so hopefully this will save some pain. All you need to do is change the property to a secure property.

<Property Id='SERVER_LISTEN_URL' Secure='yes'>
      <RegistrySearch Id='ServerListenUrlRegSearch' Root='HKLM'
                      Key='SOFTWARE\$(var.Manufacturer)\$(var.Name)'
                      Name='ServerListenUrl'
                      Type='raw' Win64='no' />
</Property>



回答2:


Secure properties can pass their content from the client process (run in user context) to the server process (run in system context) during an "elevated install". In other words an install that is invoked by a non-admin user. Don't be too generous about what properties are made secure, but definitely add all properties used in the Upgrade table, and any special ones used in the GUI for crucial information as you have done.

http://msdn.microsoft.com/en-us/library/aa371571(v=vs.85).aspx



来源:https://stackoverflow.com/questions/5996613/wix-installer-blanks-out-registry-setting-when-repairing

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!