Page 1 of 1
Use a new environment variable immediately in setup
Posted: Wed Feb 04, 2015 8:10 am
by alibaba
Hello,
in my setup an new environment variable for PATH is created. After Apply install I am executing an .exe file that needs this new PATH env. variable.
How can I achive it that the .exe can 'see' this new variable?
I am looking for something like this batch command:
setlocal
path=C:\Program Files\Pervasive Software\PSQL\bin\;%path%
Any idea?
Re: Use a new environment variable immediately in setup
Posted: Wed Feb 04, 2015 12:45 pm
by FrancescoT
Dear Alibaba,
maybe I'm missing something, but why don't you use "GetEnvironmentVariable" WIN API from your EXE?
Regards
Re: Use a new environment variable immediately in setup
Posted: Thu Feb 05, 2015 6:09 am
by alibaba
The problem is that this environment variable is created in the same 'process', so this variable is not visible to the function.
only in a new process the newly created env. variable is visible.
For example, if I start the IA setup from a batch: The setup creates the env variable and afterwards in the batch an .exe is called that reads this env. variable. The .exe is not able to read this variable. Only if I run the command: "setlocal path=C:\Program Files\Pervasive Software\PSQL\bin\;%path%" between IA setup and .exe, the .exe is able to access the env. variable.
Re: Use a new environment variable immediately in setup
Posted: Thu Feb 05, 2015 1:39 pm
by FrancescoT
Dear Alibaba,
sorry, but I still believe to miss something.
If the environment variable is created by the setup and then once terminated you launch the EXE, these will run under two different processes.
isn't it?
Regards
Re: Use a new environment variable immediately in setup
Posted: Fri Feb 06, 2015 4:56 am
by alibaba
no, if I start the setup and then the .exe both from one batch file, then they are running in the same process. At least the environment variable created in the setup is not visibe to the .exe.
But I don't want to use a batch, this was just for illustration. I want to call the .exe in the IA setup at the end. But there is the same problem, the newly created environment variable is not visible to the .exe at the end of the setup. How can I achive that the environment variable can be used by the .exe.
I also tried run program as and entered the Environment in the dialog but this didn't work...
Re: Use a new environment variable immediately in setup
Posted: Fri Feb 06, 2015 11:26 am
by FrancescoT
Dear Alibaba,
... doing a Google search I found the folowing discussion ... If you haven't already, I suggest you to have a look.
http://stackoverflow.com/questions/3636055/how-to-modify-the-path-variable-definitely-through-the-command-line-in-windowsHope this helps you.
Regards