WiX - How to get different registry keys for all users and one user

My program will be installed on the path in the registry, which has two different values ​​for one user and all users.

So, I would like to have something like:

<Property Id="MYINSTALLDIR">
    if single user, then <RegistrySearch Id='MyRegistry' Type='raw' Root='HKCU' Key='Software\MyApp\Foo' Name='InstallDir' />
    else if ALLUSERS, then <RegistrySearch Id='MyRegistry' Type='raw' Root='HKLM' Key='Software\MyApp\Foo' Name='InstallDir' />
</Property>    

Is it possible?

+2
source share
2 answers

Run two registry queries for two different properties, and then use the custom SetProperty action to assign one of the two properties to a real property, on the basis of which there is data, and who has a higher priority (use conditions to control execution).

+2
source

Finally, now it works ...

wxs ALLUSER=1 2 msiexec, HKLM.

<Property Id="INSTALLDIR1">
    <RegistrySearch Id='RegistryCU' Type='raw' Root='HKCU' Key='Software\Foo' Name='InstallDir' />
</Property>

<Property Id="INSTALLDIR2">
    <RegistrySearch Id='RegistryLM' Type='raw' Root='HKLM' Key='Software\Foo' Name='InstallDir' />
</Property>

<CustomAction Id="PerUserInstall"    Property="InstallDir" Value="[INSTALLDIR1]" Execute="immediate" />
<CustomAction Id="PerMachineInstall" Property="InstallDir" Value="[INSTALLDIR2]" Execute="immediate" /> 
<InstallExecuteSequence>
    <Custom Action="PerUserInstall"    After="AppSearch">ALLUSERS="" OR (ALLUSERS=2 AND (NOT Privileged))</Custom>      
    <Custom Action="PerMachineInstall" After="AppSearch">ALLUSERS=1  OR (ALLUSERS=2 AND Privileged)</Custom>
</InstallExecuteSequence>

HKCU, HKLM , , - ALLUSER .

0

All Articles