1 |
joko |
1.8 |
; VpnDial.nsi |
2 |
janosch |
1.13 |
; $Id: vpn.nsi,v 1.12 2005/11/22 17:35:04 janosch Exp $ |
3 |
joko |
1.8 |
; |
4 |
|
|
; This script can install VpnDial, |
5 |
|
|
; has uninstall support and (optionally) installs start menu shortcuts. |
6 |
|
|
; |
7 |
|
|
|
8 |
|
|
!include "MUI.nsh" |
9 |
|
|
!include "variables-declaration.nsi" |
10 |
|
|
!include "string_functions.nsi" |
11 |
|
|
!include "file_functions.nsi" |
12 |
|
|
!include "ras_functions.nsi" |
13 |
|
|
|
14 |
|
|
|
15 |
|
|
; -------------------------------- |
16 |
|
|
; The name of the installer |
17 |
|
|
; -------------------------------- |
18 |
|
|
Name "VpnDial" |
19 |
|
|
|
20 |
|
|
; The file to write |
21 |
|
|
OutFile "VpnDial-Setup.exe" |
22 |
|
|
|
23 |
|
|
; The default installation directory |
24 |
|
|
InstallDir $PROGRAMFILES\NetFragOrg\VpnDial |
25 |
|
|
|
26 |
|
|
; Registry key to check for directory (so if you install again, it will |
27 |
|
|
; overwrite the old one automatically) |
28 |
|
|
InstallDirRegKey HKLM "Software\NSIS_VpnDial" "Install_Dir" |
29 |
|
|
|
30 |
|
|
SetOverwrite on |
31 |
|
|
|
32 |
|
|
|
33 |
|
|
; -------------------------------- |
34 |
|
|
; (MUI) Interface Settings |
35 |
|
|
; -------------------------------- |
36 |
|
|
!define MUI_ABORTWARNING |
37 |
|
|
!define MUI_COMPONENTSPAGE_NODESC |
38 |
|
|
!define MUI_ICON "key.ico" |
39 |
|
|
!define MUI_UNICON "key.ico" |
40 |
|
|
|
41 |
|
|
|
42 |
|
|
; -------------------------------- |
43 |
|
|
; Pages |
44 |
|
|
; -------------------------------- |
45 |
|
|
|
46 |
|
|
UninstPage uninstConfirm |
47 |
|
|
UninstPage instfiles |
48 |
|
|
|
49 |
|
|
!insertmacro MUI_PAGE_WELCOME |
50 |
|
|
Page custom SetupPage1 |
51 |
|
|
Page custom SetupPage2 |
52 |
|
|
Page custom SetupPage3 |
53 |
|
|
!insertmacro MUI_PAGE_COMPONENTS |
54 |
|
|
!insertmacro MUI_PAGE_DIRECTORY |
55 |
|
|
!insertmacro MUI_PAGE_INSTFILES |
56 |
|
|
|
57 |
|
|
!insertmacro MUI_UNPAGE_CONFIRM |
58 |
|
|
!insertmacro MUI_UNPAGE_INSTFILES |
59 |
|
|
!insertmacro MUI_LANGUAGE "German" |
60 |
|
|
|
61 |
|
|
|
62 |
|
|
; -------------------------------- |
63 |
|
|
; .onInit |
64 |
|
|
; -------------------------------- |
65 |
|
|
|
66 |
|
|
Function .onInit |
67 |
|
|
|
68 |
|
|
|
69 |
|
|
System::Call 'kernel32::CreateMutexA(i 0, i 0, t "myMutex") i .r1 ?e' |
70 |
|
|
Pop $R0 |
71 |
|
|
StrCmp $R0 0 +3 |
72 |
|
|
MessageBox MB_OK|MB_ICONEXCLAMATION "Die Installation läuft bereits." |
73 |
|
|
Abort |
74 |
|
|
|
75 |
|
|
!insertmacro MUI_INSTALLOPTIONS_EXTRACT "vpndial_settings.ini" |
76 |
|
|
!insertmacro MUI_INSTALLOPTIONS_EXTRACT "vpndial_settings_net.ini" |
77 |
|
|
!insertmacro MUI_INSTALLOPTIONS_EXTRACT "vpndial_settings_cert.ini" |
78 |
|
|
FunctionEnd |
79 |
|
|
|
80 |
|
|
Function SetupPage1 |
81 |
|
|
; custom page |
82 |
|
|
; see: http://nsis.sourceforge.net/Docs/Modern%20UI/Readme.html#customPages |
83 |
|
|
; and: http://nsis.sourceforge.net/Docs/InstallOptions/Readme.html |
84 |
|
|
!insertmacro MUI_HEADER_TEXT "VpnDial Einstellungen" "Bitte füllen Sie folgende Angaben aus" |
85 |
|
|
!insertmacro MUI_INSTALLOPTIONS_DISPLAY "vpndial_settings.ini" |
86 |
|
|
FunctionEnd |
87 |
|
|
|
88 |
|
|
Function SetupPage2 |
89 |
|
|
!insertmacro MUI_HEADER_TEXT "VpnDial Einstellungen" "Bitte füllen Sie folgende Angaben aus" |
90 |
|
|
!insertmacro MUI_INSTALLOPTIONS_DISPLAY "vpndial_settings_net.ini" |
91 |
|
|
FunctionEnd |
92 |
|
|
|
93 |
|
|
Function SetupPage3 |
94 |
|
|
!insertmacro MUI_HEADER_TEXT "VpnDial Einstellungen" "Bitte füllen Sie folgende Angaben aus" |
95 |
|
|
!insertmacro MUI_INSTALLOPTIONS_DISPLAY "vpndial_settings_cert.ini" |
96 |
|
|
FunctionEnd |
97 |
|
|
|
98 |
|
|
|
99 |
|
|
; -------------------------------- |
100 |
|
|
; The stuff to install |
101 |
|
|
; -------------------------------- |
102 |
|
|
|
103 |
|
|
Section |
104 |
|
|
|
105 |
|
|
;Get Parameter from vpndial_settings.ini |
106 |
|
|
|
107 |
|
|
;Get Connectionname |
108 |
|
|
!insertmacro MUI_INSTALLOPTIONS_READ $connectionname "vpndial_settings.ini" "Field 2" "State" |
109 |
|
|
;MessageBox MB_OK $R1 |
110 |
|
|
;StrCpy $connectionname $R1 |
111 |
|
|
|
112 |
|
|
;Get Destination_host |
113 |
|
|
!insertmacro MUI_INSTALLOPTIONS_READ $destination_host "vpndial_settings.ini" "Field 3" "State" |
114 |
|
|
;MessageBox MB_OK $R2 |
115 |
|
|
;StrCpy $destination_host $R2 |
116 |
|
|
|
117 |
|
|
;Get Username |
118 |
|
|
!insertmacro MUI_INSTALLOPTIONS_READ $username "vpndial_settings.ini" "Field 4" "State" |
119 |
|
|
|
120 |
|
|
;Get Password |
121 |
|
|
!insertmacro MUI_INSTALLOPTIONS_READ $userpass "vpndial_settings.ini" "Field 8" "State" |
122 |
|
|
|
123 |
|
|
;------------------------------------------------------------------------------------------------------------- |
124 |
|
|
|
125 |
|
|
;Get Parameter from vpndial_settings_net.ini |
126 |
|
|
|
127 |
|
|
;Get Destination_net |
128 |
|
|
!insertmacro MUI_INSTALLOPTIONS_READ $R1 "vpndial_settings_net.ini" "Field 2" "State" |
129 |
|
|
!insertmacro MUI_INSTALLOPTIONS_READ $R2 "vpndial_settings_net.ini" "Field 3" "State" |
130 |
|
|
!insertmacro MUI_INSTALLOPTIONS_READ $R3 "vpndial_settings_net.ini" "Field 4" "State" |
131 |
|
|
!insertmacro MUI_INSTALLOPTIONS_READ $R4 "vpndial_settings_net.ini" "Field 7" "State" |
132 |
|
|
|
133 |
|
|
StrCpy $destination_net "$R1.$R2.$R3.$R4" |
134 |
|
|
|
135 |
|
|
;Get Destination_mask |
136 |
|
|
!insertmacro MUI_INSTALLOPTIONS_READ $R5 "vpndial_settings_net.ini" "Field 12" "State" |
137 |
|
|
!insertmacro MUI_INSTALLOPTIONS_READ $R6 "vpndial_settings_net.ini" "Field 13" "State" |
138 |
|
|
!insertmacro MUI_INSTALLOPTIONS_READ $R7 "vpndial_settings_net.ini" "Field 14" "State" |
139 |
|
|
!insertmacro MUI_INSTALLOPTIONS_READ $R8 "vpndial_settings_net.ini" "Field 15" "State" |
140 |
|
|
|
141 |
|
|
StrCpy $destination_mask "$R12.$R13.$R14.$R15" |
142 |
|
|
|
143 |
|
|
;-------------------------------------------------------------------------------------------------------------- |
144 |
|
|
|
145 |
|
|
;Get Parameter from vpndial_settings_cert.ini |
146 |
|
|
|
147 |
|
|
!insertmacro MUI_INSTALLOPTIONS_READ $cacert "vpndial_settings_cert.ini" "Field 2" "State" |
148 |
|
|
!insertmacro MUI_INSTALLOPTIONS_READ $usercert "vpndial_settings_cert.ini" "Field 3" "State" |
149 |
|
|
|
150 |
|
|
SectionEnd |
151 |
|
|
|
152 |
|
|
Section |
153 |
|
|
SetShellVarContext all |
154 |
|
|
Push $APPDATA\Microsoft\Network\Connections\Pbk\rasphone.pbk |
155 |
|
|
Push "[$connectionname]" |
156 |
|
|
Call FileSearch |
157 |
|
|
Pop $0 #Number of times found throughout |
158 |
|
|
Pop $1 #Found at all? yes/no |
159 |
|
|
Pop $2 #Number of lines found in |
160 |
|
|
StrCmp $1 yes 0 +3 |
161 |
|
|
MessageBox MB_OK "Die Verbindung $\"$connectionname$\" existiert bereits. Der Eintrag kann leider nicht doppelt angelegt werden." |
162 |
|
|
Abort |
163 |
|
|
SectionEnd |
164 |
|
|
|
165 |
|
|
Section "VpnDial" IDX_VpnDial |
166 |
|
|
|
167 |
|
|
SetOverwrite on |
168 |
|
|
|
169 |
|
|
SetDetailsPrint both |
170 |
|
|
DetailPrint "Installiere VpnDial..." |
171 |
|
|
|
172 |
|
|
;SectionIn RO |
173 |
|
|
|
174 |
|
|
; Set output path to the installation directory. |
175 |
|
|
SetOutPath $INSTDIR |
176 |
|
|
|
177 |
|
|
;CreateDirectory $INSTDIR\certs\ |
178 |
|
|
|
179 |
|
|
; Put file there |
180 |
joko |
1.10 |
File /r /x CVS "vpndial\*.*" |
181 |
joko |
1.8 |
|
182 |
|
|
; Write the installation path into the registry |
183 |
|
|
WriteRegStr HKLM Software\NSIS_VpnDial "Install_Dir" "$INSTDIR" |
184 |
|
|
|
185 |
|
|
; Write the uninstall keys for Windows |
186 |
|
|
WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\VpnDial" "DisplayName" "VpnDial" |
187 |
|
|
WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\VpnDial" "UninstallString" '"$INSTDIR\uninstall.exe"' |
188 |
|
|
WriteRegDWORD HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\VpnDial" "NoModify" 1 |
189 |
|
|
WriteRegDWORD HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\VpnDial" "NoRepair" 1 |
190 |
|
|
WriteUninstaller "uninstall.exe" |
191 |
|
|
|
192 |
|
|
SectionEnd |
193 |
|
|
|
194 |
|
|
|
195 |
|
|
|
196 |
|
|
|
197 |
|
|
; --------------------------------------------------------------------------- |
198 |
|
|
|
199 |
|
|
; pbk-Datei anpassen |
200 |
|
|
|
201 |
|
|
; --------------------------------------------------------------------------- |
202 |
|
|
|
203 |
|
|
|
204 |
|
|
|
205 |
|
|
; Verbindungsname |
206 |
|
|
Section |
207 |
|
|
DetailPrint "Installiere VPN-Verbindung..." |
208 |
|
|
Push "[##connectionname##]" #-- text to be replaced within the " " |
209 |
|
|
Push "[$connectionname]" #-- replace with anything within the " " |
210 |
|
|
Push all #-- replace all occurrences |
211 |
|
|
Push all #-- replace all occurrences |
212 |
|
|
Push "$INSTDIR\pbk\connection.pbk" #-- file to replace in |
213 |
|
|
Call AdvReplaceInFile #-- Call the Function |
214 |
|
|
SectionEnd |
215 |
|
|
|
216 |
|
|
; Gegenstelle |
217 |
|
|
Section |
218 |
|
|
Push "PhoneNumber=##destinationhost##" #-- text to be replaced within the " " |
219 |
|
|
Push "PhoneNumber=$destination_host" #-- replace with anything within the " " |
220 |
|
|
Push all #-- replace all occurrences |
221 |
|
|
Push all #-- replace all occurrences |
222 |
|
|
Push "$INSTDIR\pbk\connection.pbk" #-- file to replace in |
223 |
|
|
Call AdvReplaceInFile #-- Call the Function |
224 |
|
|
SectionEnd |
225 |
|
|
|
226 |
|
|
|
227 |
|
|
; GUID |
228 |
|
|
Section |
229 |
|
|
|
230 |
|
|
Call CreateRasGUID |
231 |
|
|
|
232 |
|
|
Pop $0 ; contains GUID |
233 |
|
|
|
234 |
|
|
Push "Guid=##guid##" #-- text to be replaced within the " " |
235 |
|
|
Push "Guid=$0" #-- replace with anything within the " " |
236 |
|
|
Push all #-- replace all occurrences |
237 |
|
|
Push all #-- replace all occurrences |
238 |
|
|
Push "$INSTDIR\pbk\connection.pbk" #-- file to replace in |
239 |
|
|
Call AdvReplaceInFile #-- Call the Function |
240 |
|
|
SectionEnd |
241 |
|
|
|
242 |
|
|
|
243 |
|
|
; Verbindungsdatei mit globaler Datei zusammenführen |
244 |
|
|
Section |
245 |
|
|
SetShellVarContext all |
246 |
|
|
Push $INSTDIR\pbk\rasphone.pbk |
247 |
|
|
Push $APPDATA\Microsoft\Network\Connections\Pbk\rasphone.pbk |
248 |
|
|
Push $INSTDIR\pbk\connection.pbk |
249 |
|
|
Call JoinFiles |
250 |
|
|
CopyFiles $APPDATA\Microsoft\Network\Connections\Pbk\rasphone.pbk $INSTDIR\pbk\rasphone_orig.pbk |
251 |
|
|
CopyFiles $INSTDIR\pbk\rasphone.pbk $APPDATA\Microsoft\Network\Connections\Pbk\rasphone.pbk |
252 |
|
|
SetShellVarContext current |
253 |
|
|
SectionEnd |
254 |
|
|
|
255 |
|
|
Section |
256 |
|
|
nsExec::Exec "$INSTDIR\bin\VpnDial.exe --setup $connectionname --user $username --pass $userpass" |
257 |
|
|
SectionEnd |
258 |
|
|
|
259 |
|
|
Section |
260 |
|
|
;nsExec::Exec "$INSTDIR\bin\certmgr.exe -add -c $INSTDIR\certs\$cacert -s -r localMachine root" |
261 |
janosch |
1.9 |
nsExec::Exec "$INSTDIR\bin\certmgr.exe -add -c $cacert -s -r localMachine root" |
262 |
joko |
1.8 |
SectionEnd |
263 |
|
|
|
264 |
|
|
Section |
265 |
|
|
;nsExec::Exec "$INSTDIR\bin\winhttpcertcfg.exe -g -i $INSTDIR\certs\$usercert -c LOCAL_MACHINE\My -a $currentuser" |
266 |
|
|
nsExec::Exec "$INSTDIR\bin\winhttpcertcfg.exe -g -i $usercert -c LOCAL_MACHINE\My -a $currentuser" |
267 |
|
|
SectionEnd |
268 |
|
|
|
269 |
|
|
; Optional section (can be disabled by the user) |
270 |
|
|
Section "Startmenü-Einträge" IDX_STARTMENU |
271 |
|
|
|
272 |
|
|
SetDetailsPrint both |
273 |
|
|
DetailPrint "Installiere Startmenü-Einträge und Desktop-Verknüpfungen..." |
274 |
|
|
|
275 |
|
|
CreateDirectory "$SMPROGRAMS\VpnDial" |
276 |
|
|
CreateShortCut "$SMPROGRAMS\VpnDial\Uninstall.lnk" "$INSTDIR\uninstall.exe" "" "$INSTDIR\uninstall.exe" 0 |
277 |
janosch |
1.11 |
CreateShortCut "$SMPROGRAMS\VpnDial\VpnMonitor-$connectionname.lnk" "$INSTDIR\bin\VpnDial.exe" "--gui --up --monitor $connectionname --net $destination_net --mask $destination_mask" "$INSTDIR\bin\VpnDial.exe" 0 |
278 |
janosch |
1.13 |
CreateShortCut "$SMPROGRAMS\VpnDial\VpnDial-$connectionname.lnk" "$INSTDIR\bin\VpnDial.exe" "--dial --gui --up --monitor $connectionname --net $destination_net --mask $destination_mask" "$INSTDIR\bin\VpnDial.exe" 0 |
279 |
joko |
1.8 |
CreateShortCut "$SMPROGRAMS\VpnDial\ZertifikatsVerwaltung.lnk" "$INSTDIR\links\IPSec.msc" "" "$INSTDIR\links\IPSec.msc" 0 |
280 |
|
|
;CreateShortCut "$SMPROGRAMS\VpnDial\README.lnk" "$INSTDIR\doc\README.txt" "" "$INSTDIR\doc\README.txt" 0 |
281 |
|
|
;CreateShortCut "$SMPROGRAMS\VpnDial\README-HTML.lnk" "$INSTDIR\doc\README.htm" "" "$INSTDIR\doc\README.htm" 0 |
282 |
|
|
|
283 |
|
|
CopyFiles "$INSTDIR\links\Netzwerkverbindung*" "$SMPROGRAMS\VpnDial\" |
284 |
|
|
|
285 |
|
|
SectionEnd |
286 |
|
|
|
287 |
|
|
|
288 |
|
|
; -------------------------------- |
289 |
|
|
; Uninstaller |
290 |
|
|
; -------------------------------- |
291 |
|
|
|
292 |
|
|
Section "Uninstall" IDX_UNINSTALL |
293 |
|
|
|
294 |
|
|
; ------------------ |
295 |
|
|
; uninstall VpnDial |
296 |
|
|
; ------------------ |
297 |
|
|
|
298 |
|
|
; Remove registry keys |
299 |
|
|
DeleteRegKey HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\VpnDial" |
300 |
|
|
DeleteRegKey HKLM SOFTWARE\NSIS_VpnDial |
301 |
|
|
|
302 |
|
|
;Remove files and uninstaller |
303 |
|
|
;Delete $INSTDIR\makensisw.exe |
304 |
|
|
;Delete $INSTDIR\uninstall.exe |
305 |
|
|
;Delete "$INSTDIR\*.*" |
306 |
|
|
|
307 |
|
|
; Remove shortcuts, if any |
308 |
|
|
Delete "$SMPROGRAMS\VpnDial\*.*" |
309 |
|
|
|
310 |
|
|
; Remove directories used |
311 |
|
|
RMDir /r "$SMPROGRAMS\VpnDial" |
312 |
|
|
RMDir /r "$INSTDIR" |
313 |
|
|
|
314 |
|
|
SectionEnd |