Use a new environment variable immediately in setup

Got a problem you cannot solve? Try here.
alibaba
Posts: 314
Joined: Fri Jun 26, 2009 8:46 am
Location: Thuringia, Germany

Use a new environment variable immediately in setup

Postby alibaba » Wed Feb 04, 2015 8:10 am

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?

FrancescoT
Site Admin
Posts: 5361
Joined: Sun Aug 22, 2010 4:28 am

Re: Use a new environment variable immediately in setup

Postby FrancescoT » Wed Feb 04, 2015 12:45 pm

Dear Alibaba,

maybe I'm missing something, but why don't you use "GetEnvironmentVariable" WIN API from your EXE?

Regards
Francesco Toscano
InstallAware Software

White Papers (HowTos) - http://www.installaware.com/publication ... papers.htm
Publications - http://www.installaware.com/publications-review.htm
InstallAware Help -F1 anywhere in the InstallAware IDE

alibaba
Posts: 314
Joined: Fri Jun 26, 2009 8:46 am
Location: Thuringia, Germany

Re: Use a new environment variable immediately in setup

Postby alibaba » Thu Feb 05, 2015 6:09 am

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.

FrancescoT
Site Admin
Posts: 5361
Joined: Sun Aug 22, 2010 4:28 am

Re: Use a new environment variable immediately in setup

Postby FrancescoT » Thu Feb 05, 2015 1:39 pm

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
Francesco Toscano
InstallAware Software

White Papers (HowTos) - http://www.installaware.com/publication ... papers.htm
Publications - http://www.installaware.com/publications-review.htm
InstallAware Help -F1 anywhere in the InstallAware IDE

alibaba
Posts: 314
Joined: Fri Jun 26, 2009 8:46 am
Location: Thuringia, Germany

Re: Use a new environment variable immediately in setup

Postby alibaba » Fri Feb 06, 2015 4:56 am

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...

FrancescoT
Site Admin
Posts: 5361
Joined: Sun Aug 22, 2010 4:28 am

Re: Use a new environment variable immediately in setup

Postby FrancescoT » Fri Feb 06, 2015 11:26 am

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-windows

Hope this helps you.

Regards
Francesco Toscano
InstallAware Software

White Papers (HowTos) - http://www.installaware.com/publication ... papers.htm
Publications - http://www.installaware.com/publications-review.htm
InstallAware Help -F1 anywhere in the InstallAware IDE


Return to “Technical Support”

Who is online

Users browsing this forum: No registered users and 16 guests