1
1
!include " MUI2.nsh"
2
2
!include " StrFunc.nsh"
3
- ${Using:StrFunc} StrStr
4
3
${Using:StrFunc} UnStrStr
5
- ${Using:StrFunc} UnStrRep
6
4
7
5
Name " Elixir"
8
6
ManifestDPIAware true
@@ -16,7 +14,6 @@ Page custom CheckOTPPageShow CheckOTPPageLeave
16
14
17
15
var Dialog
18
16
var DownloadOTPLink
19
- var InstalledERTSVersion
20
17
var InstalledOTPRelease
21
18
var OTPPath
22
19
Function CheckOTPPageShow
@@ -30,11 +27,10 @@ Function CheckOTPPageShow
30
27
${EndIf}
31
28
32
29
EnumRegKey $0 HKLM " SOFTWARE\WOW6432NODE\Ericsson\Erlang" 0
33
- ReadRegStr $1 HKLM " SOFTWARE\WOW6432NODE\Ericsson\Erlang\$0" " "
34
- StrCpy $InstalledERTSVersion $0
35
- StrCpy $OTPPath $1
30
+ ReadRegStr $0 HKLM " SOFTWARE\WOW6432NODE\Ericsson\Erlang\$0" " "
31
+ StrCpy $OTPPath $0
36
32
37
- ${If} $1 == " "
33
+ ${If} $OTPPath == " "
38
34
${NSD_CreateLabel} 0 0 100 % 20u " Couldn't find existing Erlang/OTP installation. Click the link below to download and install it before proceeding."
39
35
${NSD_CreateLink} 0 25u 100 % 20u " Download Erlang/OTP ${OTP_RELEASE}"
40
36
Pop $DownloadOTPLink
@@ -103,62 +99,55 @@ Function FinishPageShow
103
99
104
100
EnumRegKey $0 HKLM " SOFTWARE\WOW6432NODE\Ericsson\Erlang" 0
105
101
ReadRegStr $0 HKLM " SOFTWARE\WOW6432NODE\Ericsson\Erlang\$0" " "
106
- StrCpy $OTPPath $0
107
- ${If} $0 != " "
108
- ${NSD_CreateCheckbox} 0 20u 195u 10u " &Add $0\bin to %PATH%"
109
- Pop $AddOTPToPathCheckbox
110
- SendMessage $AddOTPToPathCheckbox ${BM_SETCHECK} ${BST_CHECKED} 0
111
- ${EndIf}
102
+ ${NSD_CreateCheckbox} 0 20u 195u 10u " &Add $0\bin to %PATH%"
103
+ Pop $AddOTPToPathCheckbox
104
+ SendMessage $AddOTPToPathCheckbox ${BM_SETCHECK} ${BST_CHECKED} 0
112
105
113
106
nsDialogs::Show
114
107
FunctionEnd
115
108
109
+ var PathsToAdd
116
110
Function FinishPageLeave
117
111
${NSD_GetState} $AddOTPToPathCheckbox $0
118
112
${If} $0 <> ${BST_UNCHECKED}
119
- ReadRegStr $0 HKCU " Environment" " Path"
120
- ${StrStr} $1 " $0" " $OTPPath\bin"
121
- ${If} $1 == " "
122
- WriteRegExpandStr HKCU " Environment" " Path" " $OTPPath\bin;$0"
123
- ${Else}
124
- MessageBox MB_OK " $OTPPath\bin already in %PATH%"
125
- ${EndIf}
113
+ StrCpy $PathsToAdd " ;$OTPPath\bin"
126
114
${EndIf}
127
115
128
116
${NSD_GetState} $AddElixirToPathCheckbox $0
129
117
${If} $0 <> ${BST_UNCHECKED}
130
- ReadRegStr $0 HKCU " Environment" " Path"
131
- ${StrStr} $1 " $0" " $INSTDIR\bin"
132
- ${If} $1 == " "
133
- WriteRegExpandStr HKCU " Environment" " Path" " $INSTDIR\bin;$0"
134
- ${Else}
135
- MessageBox MB_OK " $INSTDIR\bin already in %PATH%"
118
+ StrCpy $PathsToAdd " $PathsToAdd;$INSTDIR\bin"
119
+ ${EndIf}
120
+
121
+ ${If} " $PathsToAdd" != " "
122
+ nsExec::ExecToStack ` "$OTPPath\bin\escript.exe" "$INSTDIR\update_system_path.erl" add "$PathsToAdd"`
123
+ Pop $0
124
+ Pop $1
125
+ ${If} $0 != 0
126
+ SetErrorlevel 5
127
+ MessageBox MB_ICONSTOP " adding paths failed with $0: $1"
128
+ Quit
136
129
${EndIf}
137
130
${EndIf}
138
131
FunctionEnd
139
132
140
133
Section " Install Elixir" SectionElixir
141
134
SetOutPath " $INSTDIR"
142
135
File /r " ${ELIXIR_DIR}\"
136
+ File " update_system_path.erl"
143
137
144
138
WriteUninstaller " Uninstall.exe"
145
139
SectionEnd
146
140
147
- ; Uninstall Page: Files
148
-
149
- !insertmacro MUI_UNPAGE_DIRECTORY
150
- !insertmacro MUI_UNPAGE_INSTFILES
151
-
152
- Section " Uninstall"
153
- RMDir /r " $INSTDIR"
154
- SectionEnd
155
-
156
- ; Uninstall Page: Finish
141
+ ; Uninstall Page: Remove from %PATH%
157
142
158
143
var RemoveOTPFromPathCheckbox
159
144
var RemoveElixirFromPathCheckbox
160
145
Function un.FinishPageShow
161
- !insertmacro MUI_HEADER_TEXT " Finish Setup" " "
146
+ !insertmacro MUI_HEADER_TEXT " Remove from %PATH%" " "
147
+
148
+ EnumRegKey $0 HKLM " SOFTWARE\WOW6432NODE\Ericsson\Erlang" 0
149
+ ReadRegStr $0 HKLM " SOFTWARE\WOW6432NODE\Ericsson\Erlang\$0" " "
150
+ StrCpy $OTPPath $0
162
151
163
152
nsDialogs::Create 1018
164
153
Pop $Dialog
@@ -168,16 +157,14 @@ Function un.FinishPageShow
168
157
${EndIf}
169
158
170
159
ReadRegStr $0 HKCU " Environment" " Path"
160
+
171
161
${UnStrStr} $1 " $0" " $INSTDIR\bin"
172
162
${If} $1 != " "
173
163
${NSD_CreateCheckbox} 0 0 195u 10u " &Remove $INSTDIR\bin from %PATH%"
174
164
Pop $RemoveElixirFromPathCheckbox
175
165
SendMessage $RemoveElixirFromPathCheckbox ${BM_SETCHECK} ${BST_CHECKED} 0
176
166
${EndIf}
177
167
178
- EnumRegKey $1 HKLM " SOFTWARE\WOW6432NODE\Ericsson\Erlang" 0
179
- ReadRegStr $1 HKLM " SOFTWARE\WOW6432NODE\Ericsson\Erlang\$1" " "
180
- StrCpy $OTPPath $1
181
168
${UnStrStr} $1 " $0" " $OTPPath\bin"
182
169
${If} $1 != " "
183
170
${NSD_CreateCheckbox} 0 20u 195u 10u " &Remove $OTPPath\bin from %PATH%"
@@ -188,22 +175,37 @@ Function un.FinishPageShow
188
175
nsDialogs::Show
189
176
FunctionEnd
190
177
178
+ var PathsToRemove
191
179
Function un.FinishPageLeave
192
- ReadRegStr $0 HKCU " Environment" " Path"
193
-
194
180
${NSD_GetState} $RemoveOTPFromPathCheckbox $1
195
181
${If} $1 <> ${BST_UNCHECKED}
196
- ${UnStrRep} $0 " $0 " " $ OTPPath\bin; " " "
182
+ StrCpy $PathsToRemove " ;$ OTPPath\bin"
197
183
${EndIf}
198
184
199
185
${NSD_GetState} $RemoveElixirFromPathCheckbox $1
200
186
${If} $1 <> ${BST_UNCHECKED}
201
- ${UnStrRep} $0 " $0 " " $INSTDIR\bin; " " "
187
+ StrCpy $PathsToRemove " $PathsToRemove; $INSTDIR\bin"
202
188
${EndIf}
203
189
204
- WriteRegExpandStr HKCU " Environment" " Path" " $0"
190
+ ${If} " $PathsToRemove" != " "
191
+ nsExec::ExecToStack ` "$OTPPath\bin\escript.exe" "$INSTDIR\update_system_path.erl" remove "$PathsToRemove"`
192
+ Pop $0
193
+ Pop $1
194
+ ${If} $0 != 0
195
+ SetErrorlevel 5
196
+ MessageBox MB_ICONSTOP " removing paths failed with $0: $1"
197
+ Quit
198
+ ${EndIf}
199
+ ${EndIf}
205
200
FunctionEnd
206
201
207
202
UninstPage custom un.FinishPageShow un.FinishPageLeave
208
203
204
+ !insertmacro MUI_UNPAGE_DIRECTORY
205
+ !insertmacro MUI_UNPAGE_INSTFILES
206
+
207
+ Section " Uninstall"
208
+ RMDir /r " $INSTDIR"
209
+ SectionEnd
210
+
209
211
!insertmacro MUI_LANGUAGE " English"
0 commit comments