Created
December 8, 2016 14:12
-
-
Save azalea/212fa179b9c7905d5a939b4ea889302c to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
!macro ProcessEnvPrependPath UN | |
;; ref: http://stackoverflow.com/a/32384667/1292238 | |
!ifndef ERROR_ENVVAR_NOT_FOUND | |
!define ERROR_ENVVAR_NOT_FOUND 203 | |
!endif | |
!if "${NSIS_PTR_SIZE}" <= 4 | |
!include LogicLib.nsh | |
Function ${UN}ProcessEnvPrependPath ; IN:Path OUT:N/A | |
System::Store S | |
Pop $1 | |
System::Call 'KERNEL32::GetEnvironmentVariable(t "PATH", t, i0)i.r0' | |
${If} $0 = 0 | |
System::Call 'KERNEL32::SetEnvironmentVariable(t "PATH", tr1)' | |
${Else} | |
StrLen $2 $1 | |
System::Call '*(&t$2,&t1,&t$0)i.r9' | |
StrCpy $3 '$1;' | |
System::Call 'KERNEL32::lstrcat(ir9, tr3)' | |
System::Call '*(&t$0)i.r8' | |
System::Call 'KERNEL32::GetEnvironmentVariable(t "PATH", ir8, ir0)i.r0' | |
System::Call 'KERNEL32::lstrcat(ir9, ir8)' | |
System::Call 'KERNEL32::SetEnvironmentVariable(t "PATH", ir9)' | |
System::Free $9 | |
${EndIf} | |
System::Store L | |
FunctionEnd | |
!endif | |
!macroend |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment