0

What is the best way to create environment variable only on first install of the application? Using NOT Installed property condition did't work out for me tho.

Luka Kovac
  • 45
  • 1
  • 8

1 Answers1

1

Custom Action: Are you using a custom action for this? There is no need to do so (propaganda against custom actions). There are built-in features in MSI to update environment variables.

WiX: Updating the Path variable using WiX is simple enough. That is a sample from the WiX makers themselves. You need to pay very close attention to how you configure that to see desired behavior. Test in all installation modes: install, repair, self-repair, uninstall, patch, major upgrade, etc...

Inlining sample from above link:

<Feature Id='Git'>
  <Component Directory='INSTALLFOLDER'>
    <RegistryValue Root='HKLM' Key='Software\Git' Name='InstallFolder' Value='[INSTALLFOLDER]' Type='string' />
    <Environment Id='UpdatePath' Name='PATH' Value='[dir6224ijVLx94XYG2KL6z4YR8qrrs]' Action='set' Part='last' System='yes' />
  </Component>
  • The documentation for the WiX Environment element.
  • And here is the MSI SDK information for the actual Environment Table in the final MSI (what is processed by Windows Installer during installation - the raw tables).

Links:

Stein Åsmul
  • 39,960
  • 25
  • 91
  • 164