How do I read an environment variable into the MSI?



Question

How do I read an environment variable into the MSI?

Answer


Check out the MSDN topic Restrictions on Property Names [Windows Installer] which says

Property names prefixed with % represent system and user environment variables.


Check out the MSDN topic Formatted [Windows Installer] which says

If a substring of the form [%environmentvariable] is found, the value of the environment variable is substituted for the substring.

Property names prefixed with % represent system and user environment variables.

Content credit also belongs to




  • Rob, Microsoft Dev and WiX Project Lead. You can get other Rob insights about developing for Windows Installer from his blog when setup isn’t just xcopy



[Author: Robert Flaming]


This posting is provided “AS IS” with no warranties, and confers no rights. Use of included script samples are subject to the terms specified at http://www.microsoft.com/info/cpyright.htm.

Comments (2)

  1. Vivek says:

    I have been trying to write an environment variable from a setup and deployment project. I realized it was not possible, or was too difficult, and ended up creating a custom action that in turn calls a managed dll. This dll does the job of changing the environment variable (in my case PATH)