Skip to content
⌘ NSIS Forum Archive

ReadEnvStr not reading correctly

5 posts

tao.shen#

ReadEnvStr not reading correctly

Hi,

It seems ReadEnvStr is not reading changes inside a given install instance.

ie, My code:
..
ExecWait "setup.exe" ; install section and set JAVA_HOME

ReadEnvStr $0 "JAVA_HOME"

ExecWait "echo $0" ; not set

__

is there some way i can reload the env str?

or is executing a new instance equivalent?

ExecWait "setup.exe" ; install section and set JAVA_HOME
ReadEnvStr $R0 COMSPEC
ExecWait '"$R0" /C echo %JAVA_HOME%'

thought id ask cos u guys seems to be on top of your game 😛
hooklee#
It depends on what setup.exe did. If it added a local environment variable, JAVA_HOME will disappear after "ExecWait setup.exe". If it added a system environment variable, you may read it from Windows Registry for WinNT/2000/XP (for win9x, you cannot read it before rebooting). For the registry entry, please search related scripts in NSIS archive.
tao.shen#
RobGrant, if you are refering to the "" around ReadEnvStr. It made no difference with or without.

hooklee, setup.exe is writing a system env variable. I see you can get around it by getting the env setting from the registry but is there no way to read it using ReadEnvStr or ExecWait '"$R0" /C echo %JAVA_HOME%'?

after execution i can open a cmd window and type:
echo %JAVA_HOME%