Search code examples
wixwix3wix3.8wix3.9

WiX configuration: Editing registry with local app data path


Our WiX installer is configured to edit the registry by adding the following value to some existing key:

Name: "Shell"

Value: "{LocalAppData}\MyApplication\MyApplication.exe"

Right now I have hard-entered the value, but this is obviously very platform- and user- specific.

<Component Id="RegistryEntries">
  <RegistryKey 
     Root="HKCU"
     Key="Software\Microsoft\Windows NT\CurrentVersion\Winlogon"
     ForceCreateOnInstall="yes" ForceDeleteOnUninstall="yes">
    <RegistryValue 
        Type="string" 
        Name="Shell" 
        Value="C:\Users\Dave\AppData\Local\MyApplication\MyApplication.exe"/>
  </RegistryKey>
</Component>

How can I determine and use the local app data folder for the system?

I am using WiX 3.9 for Visual Studio 2013.

EDIT:

I did the following, and it cleaned all registry value from that key:

<Component Id="RegistryEntries">
  <RegistryKey 
     Root="HKCU"
     Key="Software\Microsoft\Windows NT\CurrentVersion\Winlogon"
     ForceCreateOnInstall="yes" ForceDeleteOnUninstall="yes">
    <RegistryValue 
        Type="string" 
        Name="Shell" 
        Value="[LocalAppData]\MyApplication\MyApplication.exe"/>
  </RegistryKey>
</Component>

Why would this happen?

EDIT 2:

Nevermind, I see that these properties will forcefully recreate the whole key:

ForceCreateOnInstall="yes" ForceDeleteOnUninstall="yes"

Solution

  • You're create the registry value as [AppDataFolder] to resolve it to the full path.

    However, it looks like you want the path to an executable that you might be installing, so what works better is [#filekey] for that file.