Skip to content
⌘ NSIS Forum Archive

Refreshing Enviroment Variables

5 posts

mista-birdy#

Refreshing Enviroment Variables

Hi all,
I'm started to work with NSIS. It's a great installer.
But I need a little help.

After installing SQL Server, the command sqlcmd should be available for calling from commandprompt. Because SQL Server add the Commandtool Path to Enviroment Vars.

But it i can't just call sqlcmd. I have to call the full path.
I think it's because NSIS have the old enviroments vars in cache.

How can I refresh this cache so that i can just call
ExecWait 'SQLCMD ...' 
?
Brummelchen#
nsis works "life" and dont cache anything - its on your system.

either you use the PATH-Variable for those commands (dos command) or AppPath in registry.
This topic discusses how applications can expose information about themselves necessary to enable certain scenarios.


HTH
msroboto#
Right but let's say you change the PATH even manually no current running program, Command Prompt or NSIS installer will pick that up automatically without being restarted.

You can test that by opening a command prompt then changing your PATH.
The PATH is not reflected in that command prompt but if you open a new command prompt the new PATH or other environment variable will be available.

So the short answer is short of restarting the installer or starting a new installer you won't have access to the new PATH or other ENV variables.
Afrow UK#
Indeed environment variables are copied for each process on launch and therefore is up to that process to update its own environment variables if required. To do this you can use SetEnvironmentVariable in Kernel32.dll:


(Note that page uses SetEnvironmentVariableA - it should just be SetEnvironmentVariable - System plug-in calls SetEnvironmentVariableA or SetEnvironmentVariableW accordingly).

Stu
Anders#
Originally Posted by msroboto View Post
no current running program, Command Prompt or NSIS installer will pick that up automatically without being restarted.
Explorer picks up the new path...