diff options
author | David Cole <david.cole@kitware.com> | 2009-09-24 18:59:24 (GMT) |
---|---|---|
committer | David Cole <david.cole@kitware.com> | 2009-09-24 18:59:24 (GMT) |
commit | c181408ad83e7ef7b2cfaf9f16c933373135b030 (patch) | |
tree | 8e75f5d08a3775dd2e9a596b56d4aa9607f0056a /Modules/NSIS.template.in | |
parent | 815ec522eee1676cd7d6d8b2f9c7e5e3da43aee6 (diff) | |
download | CMake-c181408ad83e7ef7b2cfaf9f16c933373135b030.zip CMake-c181408ad83e7ef7b2cfaf9f16c933373135b030.tar.gz CMake-c181408ad83e7ef7b2cfaf9f16c933373135b030.tar.bz2 |
BUG: Fix issue #8177. Modify the system PATH for all users when requested during an NSIS based installer run. Thanks to Bart Janssens for the patch.
Diffstat (limited to 'Modules/NSIS.template.in')
-rw-r--r-- | Modules/NSIS.template.in | 37 |
1 files changed, 29 insertions, 8 deletions
diff --git a/Modules/NSIS.template.in b/Modules/NSIS.template.in index 8b9608e..99b3a90 100644 --- a/Modules/NSIS.template.in +++ b/Modules/NSIS.template.in @@ -251,14 +251,24 @@ Function AddToPath Goto AddToPath_done AddToPath_NT: - ReadRegStr $1 ${WriteEnvStr_RegKey} "PATH" + StrCmp $ADD_TO_PATH_ALL_USERS "1" ReadAllKey + ReadRegStr $1 ${NT_current_env} "PATH" + Goto DoTrim + ReadAllKey: + ReadRegStr $1 ${NT_all_env} "PATH" + DoTrim: StrCmp $1 "" AddToPath_NTdoIt Push $1 Call Trim Pop $1 StrCpy $0 "$1;$0" AddToPath_NTdoIt: - WriteRegExpandStr ${WriteEnvStr_RegKey} "PATH" $0 + StrCmp $ADD_TO_PATH_ALL_USERS "1" WriteAllKey + WriteRegExpandStr ${NT_current_env} "PATH" $0 + Goto DoSend + WriteAllKey: + WriteRegExpandStr ${NT_all_env} "PATH" $0 + DoSend: SendMessage ${HWND_BROADCAST} ${WM_WININICHANGE} 0 "STR:Environment" /TIMEOUT=5000 AddToPath_done: @@ -320,7 +330,12 @@ Function un.RemoveFromPath Goto unRemoveFromPath_done unRemoveFromPath_NT: - ReadRegStr $1 ${WriteEnvStr_RegKey} "PATH" + StrCmp $ADD_TO_PATH_ALL_USERS "1" unReadAllKey + ReadRegStr $1 ${NT_current_env} "PATH" + Goto unDoTrim + unReadAllKey: + ReadRegStr $1 ${NT_all_env} "PATH" + unDoTrim: StrCpy $5 $1 1 -1 # copy last char StrCmp $5 ";" +2 # if last char != ; StrCpy $1 "$1;" # append ; @@ -342,7 +357,12 @@ Function un.RemoveFromPath StrCmp $5 ";" 0 +2 # if last char == ; StrCpy $3 $3 -1 # remove last char - WriteRegExpandStr ${WriteEnvStr_RegKey} "PATH" $3 + StrCmp $ADD_TO_PATH_ALL_USERS "1" unWriteAllKey + WriteRegExpandStr ${NT_current_env} "PATH" $3 + Goto unDoSend + unWriteAllKey: + WriteRegExpandStr ${NT_all_env} "PATH" $3 + unDoSend: SendMessage ${HWND_BROADCAST} ${WM_WININICHANGE} 0 "STR:Environment" /TIMEOUT=5000 unRemoveFromPath_done: @@ -663,6 +683,11 @@ Section "-Core installation" @CPACK_NSIS_CREATE_ICONS_EXTRA@ CreateShortCut "$SMPROGRAMS\$STARTMENU_FOLDER\Uninstall.lnk" "$INSTDIR\Uninstall.exe" + ;Read a value from an InstallOptions INI file + !insertmacro MUI_INSTALLOPTIONS_READ $DO_NOT_ADD_TO_PATH "NSIS.InstallOptions.ini" "Field 2" "State" + !insertmacro MUI_INSTALLOPTIONS_READ $ADD_TO_PATH_ALL_USERS "NSIS.InstallOptions.ini" "Field 3" "State" + !insertmacro MUI_INSTALLOPTIONS_READ $ADD_TO_PATH_CURRENT_USER "NSIS.InstallOptions.ini" "Field 4" "State" + ; Write special uninstall registry entries Push "StartMenu" Push "$STARTMENU_FOLDER" @@ -688,10 +713,6 @@ SectionEnd Section "-Add to path" Push $INSTDIR\bin - ;Read a value from an InstallOptions INI file - !insertmacro MUI_INSTALLOPTIONS_READ $DO_NOT_ADD_TO_PATH "NSIS.InstallOptions.ini" "Field 2" "State" - !insertmacro MUI_INSTALLOPTIONS_READ $ADD_TO_PATH_ALL_USERS "NSIS.InstallOptions.ini" "Field 3" "State" - !insertmacro MUI_INSTALLOPTIONS_READ $ADD_TO_PATH_CURRENT_USER "NSIS.InstallOptions.ini" "Field 4" "State" StrCmp "@CPACK_NSIS_MODIFY_PATH@" "ON" 0 doNotAddToPath StrCmp $DO_NOT_ADD_TO_PATH "1" doNotAddToPath 0 Call AddToPath |