Environment Variable Max Length - Advanced Installer Community
NovAtel
Posts: 13
Joined: Mon Mar 18, 2019 9:58 pm

Environment Variable Max Length

Hi,

I'm creating a user Environment Variable via System Changes > Environment. This environment variable is the path to a UWP app.
I want to be able to add multiple paths for each new version I have. If I use the prepend the option to add the new path to the environment variable during each installation so that it looks something like this...

MY_ENV_VAR =
C:\Program Files\WindowsApps\<Name>_19.11.0.0_x86__<PublisherId>;
C:\Program Files\WindowsApps\<Name>_19.10.0.0_x86__<PublisherId>;
C:\Program Files\WindowsApps\<Name>_19.09.0.0_x86__<PublisherId>;
C:\Program Files\WindowsApps\<Name>_19.08.0.0_x86__<PublisherId>;
etc.

I'm wondering what happens when the variable eventually reaches the max length. Will it fail installation? Will it push out the oldest path? Other?

Thanks
Catalin
Posts: 7852
Joined: Wed Jun 13, 2018 7:49 am

Re: Environment Variable Max Length

Hello,

At install time, we only populate the Environment table, the rest being done by the predefined support offered by Windows Installer (e.g. the predefined WriteEnvironmentStrings custom action that creates the environment variable).

From my tests so far, when the prepend option is used and when the maximum length is reached, the last n characters are removed from the queue, where n is the number of characters you have prepended to the already existing environment variable. For instance, if 6 is the maximum number and we have the following environment variable:

Code: Select all

envVar = aaaaaa;
and then we try to prepend "bbb", the environment variable will become:

Code: Select all

envVar = bbb;aaa;
Hope this helps.

Best regards,
Catalin
Catalin Gheorghe - Advanced Installer Team
Follow us: Twitter - Facebook - YouTube

Return to “Common Problems”