How to use any type of Environment Variable in MSIX

Written by Alex Marin · December 21st, 2020

#MSIX #TIPS

In a previous article we had a look on how Environment Variables work with MSIX. We now know that in MSIX, Environment Variables are redefined as AppExecutionAlias.

There's a limitation when using AppExecutionAlias, which is that by default, you can only reference Environment Variables pointing to executables -- leaving other types of Environment Variables out.

Noting this, Advanced Installer added support for all types of Environment Variables in your MSIX package.

How to Configure Environment Variables

To configure an Environment Variable in Advanced Installer, navigate to the Environment page.

There, you can add, edit or remove any Environment Variables from your package. In our case we created a variable called TESTVARIABLE, which points to C:\temp.

Environment tools

NoteIf you repackage an installation, all the environment variables detected during the operation will appear within this Environment page.

The Differences Between Environment Variables and AppExecutionAlias

The difference between Environment Variables and the AppExecutionAlias is that the AppExecutionAlias is declared globally on the system so it can be accessed by external applications while the Environment Variable is emulated only within the MSIX container.

For example, if an AppExecutionAlias is defined for a HelloWorld.exe, when you open up CMD and type HelloWorld.exe, the application will launch.

This won’t happen with the Environment Variables added through the Environment Page, since they are only emulated inside the MSIX container, and cannot be accessed externally.

If we create a standard MSIX package, add the above mentioned variable, and run the application, it will detect the Environment Variable.

Detect environment variables

NoteKeep in mind that if we search for this variable on the system, it will not be found.

The Expected Behavior of Environment Variables

The Environment Variable Edit Dialog, allows various operations and behaviors to be applied to an Environment Variable. This will look familiar to you if you worked with MSI. We wanted to follow the same logic with MSIX for operations and behaviors related to Environment Variables.

For example, if an Environment Variable is already present on the system, and we choose to update that variable, this will overwrite it in the MSIX container.

NoteThe Environment Variable on the system will not be modified. This will be overwritten only in the MSIX container of your application.

You can also append the value to an existing Environment Variable (like PATH), this change will also apply only inside the container of your application.

So keep in mind that all the settings you had available for the MSI technology are still valid in the MSIX technology, with the exception that the environment variables form an MSIX package are visible only inside the container of that application and not for other applications installed on the machine.

Video Tutorial - Environment Variables in MSIX

Conclusion

The main thing to remember is that AppExecutionAlias is not the same with Environment Variables. Also, Environment Variables are only emulated inside the MSIX container, and cannot be accessed from the system.

With Advanced Installer's additional predefined fixups, you can overcome the limitations set by the AppExecutionAlias and get support for all Environment Variables in your MSIX packages and applications.

Subscribe to Our Newsletter

Sign up for free and be the first to receive the latest news, videos, exclusive How-Tos, and guides from Advanced Installer.

Comments: