Forum Discussion
Pollewops
Sep 21, 2021Iron Contributor
How to set Environment Variables
Tim Mangan I tried to set a environment variable using HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Session Manager\Environment, but that is not being picked up by the package. The configured variable does not appear in the package. Seems to be the same issue as with App-V 5.1. There is does not work also.
So I tried using the PSF tooling. My config.json is configured like
{
"enableReportError": true,
"applications": [],
"processes": [],
"config": {
"dll": "EnvVarFixup32.dll",
"EnvVars": [{
"name": "APP_HOME",
"value": "C:\\Program Files\\Test\\Test",
"useregistry": "false"
},
{
"name": "APP_TEST1",
"value": "TestTestTest",
"useregistry": "false"
},
{
"name": "APP_TEST2",
"value": "VFS\\ProgramFilesX64\\Zulu",
"useregistry": "false"
},
{
"name": "JAVA_HOME",
"value": "C:\\Program Files\\Zulu\\zulu-8-jre\\bin",
"useregistry": "false"
}
]
}
}
But after deploying the package, none of the environment variables do appear in by cmd process. What am i doing wrong. I also added the file EnvVarFixup32.dll to the root of the package.
- PollewopsIron Contributor
TIMOTHY_MANGAN We did some further testing with the variables and found out the following.
Using the examples decribed in MSIX-PackageSupportFramework/readme.md at develop · TimMangan/MSIX-PackageSupportFramework · GitHub we use:
{ "dll": "EnvVarFixup.dll", "config": { "EnvVars": [{ "name": "ENVTEST1", "value": "Test1!", "useregistry": "false" },
But this is not working. Why, because in the code the envVars is case-sensitive. When using envVars it is all working 😉 EnvVars is wrong and envVars is working.
According to the debug logs we see it is working.
However when starting a cmd and dump the environment variables, we do not see them available. Any idea why?
- Thanks for the note on case sensitivity. Yes, the json is case sensitive and apparently the readme is incorrect; in that case I'll update the readme.
As to the other question, the package environment variables are not implemented in a list form (we have no intercept for that), but if you were to try to use the variable in a command inside that cmd window you should find that it works. As I don't see apps trying to list the variables before using them I don't think we need to fix that. But let me know if I'm wrong about that.- PollewopsIron ContributorSo in a cmd, the SET command wont’t list the configured variable, but an ECHO %TESTVAR% does or should display it?