Forum Discussion
OneFiftyLashes
Mar 17, 2023Copper Contributor
Environment variables in MSIX package wont be used by AVD session host
Hi, We've been struggling with environment variables in MSIX packages. The package is created with Microsoft's MSIX Packaging Tool and a script was used under capture. Script is adding environment v...
Aniket_Banerjee
Apr 27, 2023Former Employee
As I mentioned in my previous comment, we had created a test application. The config file was in the format:
{
"applications":
[
{
"id": "ENVVARIABLETEST",
"executable": "VFS/EnvVariableTest.exe"
}
],
"processes":
[
{
"executable": "PsfLauncher.*"
},
{
"executable": ".*",
"fixups":
[
{
"dll": "EnvVarFixup.dll",
"config":
{
"envVars":
[
{
"name": "Test1",
"value": "Value1",
"useregistry": "false"
},
{
"name": "Test2",
"value": "Value2",
"useregistry": "false"
},
{
"name": "Test3",
"value": "Value3",
"useregistry": "false"
}
]
}
}
]
}
]
}
HoratiuV
Jul 12, 2023Copper Contributor
Have you managed to make this fixup working for PATH Environment Variable?
- Ferry_van_GelderenJul 25, 2023Copper ContributorAdding environment variables to your MSIX packaged applications can be done as session environment variables but unfortunatly it can be a bit of a hassle. Existing environment variables set for both the system and user will be available for any running proces but any new (or changed) variables added to the registry inside the MSIX container will not be loaded when starting a process from the MSIX container. These registry entries are there so the system will know what environment variables to set during system startup and user login. Setting session environment variables can be done by a proces that will set these environment variables and then starting the program that uses these variables (like using a batch file). You can create a script that set these environment variables for the current session but al the script operators like Powershell.exe or cmd.exe are not part of the MSIX container by default and MSIX entry points (shortcuts) can only point to the executable files that are part of the MSIX container. Using the PSF tooling it is possible to execute a powershell script but from my experience the session environment variables are gone when the script is closed and the main program is started. You can let the powershell script also start the main program after setting the session environment variables but i have not tested this yet.
You may also want to take a look at a small tool i created called MSIX Helper that also handles setting (session) environment variables for your applications running from the MSIX container. You can find it on my Github page if you want to try it.
https://github.com/FvGelderen/AutoHotKey/tree/MSIX-Helper/MSIX%20Helper%201.0/Bin
Please read the provided documentation before using it. Any feedback will be appreciated.- mohant1850Jun 13, 2024Copper Contributor
Ferry_van_Gelderencan you please elaborate steps or process to handle path environment variables.
- Fiza_AzmiJun 25, 2024
Microsoft
mohant1850
MSIX Packaging tool now supports adding PSF Fixups for Environment Variables. Here is a tutorial video.