Skip to content

Commit f4a17ce

Browse files
Fix enviornment variable setting and paths
This will: + Make CEDEV a global system variable + Prepend rather than append to the path + Allow for spaces in the path automatically
1 parent 3938893 commit f4a17ce

File tree

1 file changed

+11
-50
lines changed

1 file changed

+11
-50
lines changed

tools/installer/installer.nsi

Lines changed: 11 additions & 50 deletions
Original file line numberDiff line numberDiff line change
@@ -21,16 +21,15 @@
2121
;--------------------------------
2222
;Interface and defines
2323

24+
!define env_hklm 'HKLM "SYSTEM\CurrentControlSet\Control\Session Manager\Environment"'
2425
!define env_hkcu 'HKCU "Environment"'
2526
!define MUI_ABORTWARNING
2627
!define MUI_ICON "icon.ico"
2728

2829
;--------------------------------
2930
;Pages
3031

31-
!define MUI_PAGE_CUSTOMFUNCTION_LEAVE "DirectoryLeave"
3232
!insertmacro MUI_PAGE_DIRECTORY
33-
3433
!insertmacro MUI_PAGE_INSTFILES
3534

3635
;--------------------------------
@@ -44,61 +43,23 @@
4443
Section ""
4544

4645
SetOutPath "$INSTDIR"
47-
48-
File /r ${DIST_PATH}\*.*
49-
50-
ReadRegStr $R1 ${env_hkcu} "CEDEV"
51-
${EnvVarUpdate} $0 "PATH" "R" "HKLM" "$R1\bin"
5246

53-
${EnvVarUpdate} $0 "PATH" "A" "HKLM" "$INSTDIR\bin"
54-
55-
WriteRegExpandStr ${env_hkcu} "CEDEV" "$INSTDIR"
56-
57-
SendMessage ${HWND_BROADCAST} ${WM_WININICHANGE} 0 "STR:Environment" /TIMEOUT=5000
58-
59-
SectionEnd
47+
GetFullPathName /SHORT $0 $INSTDIR
48+
StrCpy $INSTDIR $0
6049

61-
;--------------------------------
62-
;Check for spaces
50+
File /r ${DIST_PATH}\*.*
6351

64-
Function DirectoryLeave
52+
DeleteRegValue ${env_hkcu} "CEDEV"
53+
ReadRegStr $R1 ${env_hklm} "CEDEV"
6554

66-
Push $INSTDIR
67-
Call CheckForSpaces
68-
Pop $R0
69-
StrCmp $R0 0 NoSpaces
55+
${EnvVarUpdate} $0 "PATH" "R" "HKLM" "$R1\bin"
56+
${EnvVarUpdate} $0 "PATH" "P" "HKLM" "$INSTDIR\bin"
7057

71-
MessageBox MB_OK|MB_ICONEXCLAMATION "Error: The Installaton directory \
72-
contains a space character.$\nPlease ensure no spaces are in the path before installing."
73-
Abort
58+
WriteRegExpandStr ${env_hklm} "CEDEV" "$INSTDIR"
7459

75-
NoSpaces:
76-
77-
FunctionEnd
60+
SendMessage ${HWND_BROADCAST} ${WM_WININICHANGE} 0 "STR:Environment" /TIMEOUT=5000
7861

79-
Function CheckForSpaces
80-
81-
Exch $R0
82-
Push $R1
83-
Push $R2
84-
Push $R3
85-
StrCpy $R1 -1
86-
StrCpy $R3 $R0
87-
StrCpy $R0 0
88-
loop:
89-
StrCpy $R2 $R3 1 $R1
90-
IntOp $R1 $R1 - 1
91-
StrCmp $R2 "" done
92-
StrCmp $R2 " " 0 loop
93-
IntOp $R0 $R0 + 1
94-
Goto loop
95-
done:
96-
Pop $R3
97-
Pop $R2
98-
Pop $R1
99-
Exch $R0
100-
101-
FunctionEnd
62+
SectionEnd
10263

10364
;--------------------------------
10465
; Find system drive

0 commit comments

Comments
 (0)