Feature #26

Let NSIS installer replace the GMT_SHAREDIR environment variable instead of appending to it

Added by Florian almost 6 years ago. Updated over 4 years ago.

Status:ClosedStart date:2012-03-03
Priority:NormalDue date:
Assignee:Joaquim% Done:

0%

Category:-
Target version:-
Platform:

Description

Seems to be configurable in cmake/modules/NSIS.template.in (search for ADD_TO_PATH_ALL_USERS)


Related issues

Related to Feature #18: Guess the location of the share directory on Windows base... Feedback 2012-03-02
Related to Bug #29: NSIS installer does not set the path (Windows) Closed 2012-03-03

History

#1 Updated by Joaquim almost 6 years ago

Florian Wobbe wrote:

Seems to be configurable in cmake/modules/NSIS.template.in (search for ADD_TO_PATH_ALL_USERS)

I don't know what to do with it. Tried a couple of things but all failed

- Tried to call un.RemoveFromEnvVar before AddToEnvVar at line 891 and it errors saying I can't use a un.func inside a non uninstall section

- Tried without the 'un.' and it says RemoveFromEnvVar needs to be prepended with an 'un.'

- Found a EnvVarUpdate function but it basically gives the same error as in my first attempt.

#2 Updated by Florian almost 6 years ago

Seems to be configurable in cmake/modules/NSIS.template.in (search for ADD_TO_PATH_ALL_USERS)

I don't know what to do with it. Tried a couple of things but all failed

- Tried to call un.RemoveFromEnvVar before AddToEnvVar at line 891 and it errors saying I can't use a un.func inside a non uninstall section

- Tried without the 'un.' and it says RemoveFromEnvVar needs to be prepended with an 'un.'

- Found a EnvVarUpdate function but it basically gives the same error as in my first attempt.

I won't be much help here I'm afraid. I have seen this manual: http://nsis.sourceforge.net/Path_Manipulation. Maybe you find something useful on google: un.RemoveFromEnvVar

#3 Updated by Joaquim almost 6 years ago

I won't be much help here I'm afraid. I have seen this manual: http://nsis.sourceforge.net/Path_Manipulation. Maybe you find something useful on google: un.RemoveFromEnvVar

That was exactly were I dug the info for my attempts.

#4 Updated by Florian almost 6 years ago

I would favor dropping the support for setting GMT_SHAREDIR from the NSIS installer. Feature #18 should be implemented instead ASAP. This obsoletes this feature request.

#5 Updated by Joaquim almost 6 years ago

Florian Wobbe wrote:

I would favor dropping the support for setting GMT_SHAREDIR from the NSIS installer. Feature #18 should be implemented instead ASAP. This obsoletes this feature request.

Frankly, I am getting tired of this matter and above all the way of dealing with it.

#6 Updated by Joaquim almost 6 years ago

  • Status changed from New to Feedback

Implemented a partial solution that works when installing to Current User. It directly writes the GMT5_SHAREDIR env variable with WriteRegExpandStr.

#7 Updated by Florian almost 6 years ago

Implemented a partial solution that works when installing to Current User. It directly writes the GMT5_SHAREDIR env variable with WriteRegExpandStr.

Looks good to me. To make it more generic, you could benefit from these defines:

!ifndef WriteEnvStr_RegKey
  !ifdef ALL_USERS
    !define WriteEnvStr_RegKey \
       'HKLM "SYSTEM\CurrentControlSet\Control\Session Manager\Environment"'
  !else
    !define WriteEnvStr_RegKey 'HKCU "Environment"'
  !endif
!endif
and then maybe define a function
; ReplaceEnvVar - Adds the given value to the given environment var
;         Input - head of the stack: value to add ($1)
;                 2nd on stack: environement variable ($0)

Function ReplaceEnvVar

  Exch $1 ; $1 has environment variable value
  Exch
  Exch $0 ; $0 has environment variable name

  DetailPrint "Replacing $1 with $0" 
  Push $2

  Call IsNT
  Pop $2
  StrCmp $2 0 ReplaceEnvVar_done ; 0 = not NT

  ReplaceEnvVar_NT:
      WriteRegExpandStr ${WriteEnvStr_RegKey} $0 $1
      SendMessage ${HWND_BROADCAST} ${WM_WININICHANGE} 0 "STR:Environment" /TIMEOUT=5000

  ReplaceEnvVar_done:
    Pop $2
    Pop $0
    Pop $1

FunctionEnd
and call this new function ReplaceEnvVar instead of AddToEnvVar.

#8 Updated by Joaquim over 5 years ago

  • Status changed from Feedback to Closed

#9 Updated by Florian over 4 years ago

  • Target version deleted (Candidate for next minor release)

Also available in: Atom PDF