Archive: NSIS Env Variables windows XP


NSIS Env Variables windows XP
Can someone tell me how I can get the environment vars to show up immediately after the installer is complete? In windows XP

We do not what to restart, but we would like to run an executable directly after that requires the new env vars.

Currently I use "WriteRegStr"
Is there an env vars update system call?


With this method we have to manually refresh the env vars by opening up the env vars dialog box and clicking ok.

I did look at http://nsis.sourceforge.net/Setting_...ment_Variables

System::Call 'Kernel32::SetEnvironmentVariableA(t, t) i("name", "value").r0' StrCmp $0 0 error
ExecWait ProgThatReadsEnv.exe
Goto done
error:
MessageBox MB_OK "Can't set environment variable"
done:

This way is immediately however it does not last after the installer is complete.

Thanks again,

Jason M


http://nsis.sourceforge.net/Setting_...ment_Variables

http://nsis.sourceforge.net/Setting_...ables_Examples


figured it out use SendMessage
; SendMessage tells the system to refresh/update the env vars
SendMessage ${HWND_BROADCAST} ${WM_WININICHANGE} \
0 "STR:Environment" /TIMEOUT=5000

here is what i do.
!include "WinMessages.nsh" ; sends message to the system to update env var list after we change them
;update path
ReadRegStr $R0 HKEY_CURRENT_USER Environment PATH
fileWrite $9 "ORIGINAL PATH = $R0$\r$\n"
StrCmp $R0 "" 0 skip_all_PATH ; if not empty we found the string
StrCpy $R1 "${PATH_OPENCV};${PATH_OSSIM};${PATH_OSSIM_LIB}"
WriteRegStr HKEY_CURRENT_USER Environment PATH $R1 ; write new path if different ;HKCU == HKEY_CURRENT_USER
fileWrite $9 "CURRENT PATH = $R1$\r$\n"
Goto skip_PATH
fileClose $9
; SendMessage tells the system to refresh/update the env vars
SendMessage ${HWND_BROADCAST} ${WM_WININICHANGE} \
0 "STR:Environment" /TIMEOUT=5000

http:// opengui.rightbracket.com/trac/browser/trunk/SDKs/win32/WriteEnvStr.nsh?rev=920&format=raw