Search code examples
wixwindows-installer

Create registry entry but not delete it


Working on something for Server2012 (Win8) and it's communicating with a website that uses TLS 1.2. So, for those OSes I need to add TLS 1.2 protocols since Server 2012 doesn't support on a default install. I know how to do that. I know how to not do it for a version less than Windows 10 and not doing it if it's already been enabled. The big question is:

Is there a way not using Custom Actions to create the registry entry but not delete it afterward? I'm concerned about another program maybe needing it.

For instance,

<Property Id="WIN10FOUND">
    <DirectorySearch Id="searchSystem" Path="[SystemFolder]" Depth="0">
        <FileSearch Id="searchFile" Name="advapi32.dll" MinVersion="6.3.10000.0"/>
    </DirectorySearch>
</Property>
<Property Id="TLS12CLIENTFOUND">
    <RegistrySearch Id="SearchTLS12Client" Root="HKLM" Key="SYSTEM\CurrentControlSet\Control\SecurityProviders\SCHANNEL\Protocols\TLS 1.2\Client" Name="Enabled" Type="raw"/>
</Property>

Later on in a feature,

<!-- For Server2012 add necessary registry entries to support TLS 1.2 -->
<Component Location="local" Id="Win8TLS12Registry" Guid="00000000-1111-2222-3333-123456789ABC">
    <Condition><![CDATA[not WIN10FOUND and ((not TLS12CLIENTFOUND) or (TLS12CLIENTFOUND="#0"))]]></Condition>
    <RegistryKey Root="HKLM" Key="SYSTEM\CurrentControlSet\Control\SecurityProviders\SCHANNEL\Protocols\TLS 1.2\Client" ForceCreateOnInstall="no">
        <RegistryValue Name="DisabledByDefault" Type="integer" Value="0"/>
        <RegistryValue Name="Enabled" Type="integer" Value="1"/>
    </RegistryKey>
</Component> 

If some other installer comes along, and at least tries to create the key and value, as it stands now, I think an uninstall will cause this to delete the key and value.

I've tested what I have, and if the key /value exists and is non-zero, then it does not create/set it and uninstall leaves it untouched. However, if it did not exist beforehand (or was 0), then the key / value are deleted.

Is there a way to create the key/value if they don't exist, but not delete on uninstall short of a Custom Action?


Solution

  • Sure. Make the <Component Permanent="yes".