How to create an environment variable in Qt Installer framework regardless of OS

790 Views Asked by At

How can I add a new Environment Variable to the Qt installer. I know that it should go in the .qs script something like the following:

var path = installer.environmentVariable("PATH") + ";" + installer.value("TargetDir");
component.addElevatedOperation("EnvironmentVariable","PATH",path,true);

I'm trying the above on Linux, but it's complaining about EnvironmentVariable not existing when I install my program.

1

There are 1 best solutions below

0
Eduardo Scartezini On

Well this operation is only supported on windows, but you can try do this:

component.addElevatedOperation("AppendFile", "/etc/environment", "export PATH=\"$PATH;@TargetDir@\"\n");

Warning: do this only on installation process

if (installer.isInstaller()) {
     [...]
}

If this runs on unistallation, maybe can delete other things of /etc/environment