简体   繁体   中英

How to make windows installer update a list in a Registry string value (NOT multistring)?

I need to make an installer that will have to change the registry of another application (third party). The other application has a REG_SZ (plain string, NOT multistring) with a comma-separated list of values. My value has to be appended to that list (and removed on uninstall).

ListToUpdate (REG_SZ) = "val1, val2, val3, myval"

Does Windows Installer have any built-in facility to do that? If so, (I actually don't believe in that), how to make use of it through wix?

If not, does wix itself has any extension that creates some custom actions to do that for us? Or will I have to implement my own?

You can do a registry read and get the value to a property. Then write to the same registry with the old value and your new value. This is how to do it.

Reading the old value

<Property Id="OLDVALUE">
    <RegistrySearch Id="TestReg"
                    Root="HKLM"
                    Key="Software\TestKey\TestKey2"
                    Name="Test"
                    Type="raw" />
</Property>

Writing back to the registry

<Component Guid="A7C42303-1D77-4C70-8D5C-0FD0F9158EC4" Id="REGComponent" Directory="TEST">
      <RegistryKey Root="HKLM"
                 Key="Software\TestKey\TestKey2">
        <RegistryValue Name="Test"
                       Action="write"
                       Value="[OLDVALUE], MyVal"
                       Type="string"
                       KeyPath="yes" />
      </RegistryKey>
      </Component>

If you want to delete your value on uninstall, You can write a custom action to do it. Also make sure msi should run on administrator mode, or else registry will not be modified.

我认为您必须为此创建一个自定义操作。

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM