1 |
joko |
1.7 |
; VpnDial.nsi
|
2 |
|
|
; $Id: vpn.nsi,v 1.6 2005/11/22 15:50:55 janosch Exp $
|
3 |
|
|
;
|
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 |
|
|
System::Call 'kernel32::CreateMutexA(i 0, i 0, t "myMutex") i .r1 ?e'
|
69 |
|
|
Pop $R0
|
70 |
|
|
StrCmp $R0 0 +3
|
71 |
|
|
MessageBox MB_OK|MB_ICONEXCLAMATION "Die Installation läuft bereits."
|
72 |
|
|
Abort
|
73 |
|
|
|
74 |
|
|
!insertmacro MUI_INSTALLOPTIONS_EXTRACT "vpndial_settings.ini"
|
75 |
|
|
!insertmacro MUI_INSTALLOPTIONS_EXTRACT "vpndial_settings_net.ini"
|
76 |
|
|
!insertmacro MUI_INSTALLOPTIONS_EXTRACT "vpndial_settings_cert.ini"
|
77 |
|
|
FunctionEnd
|
78 |
|
|
|
79 |
|
|
Function SetupPage1
|
80 |
|
|
; custom page
|
81 |
|
|
; see: http://nsis.sourceforge.net/Docs/Modern%20UI/Readme.html#customPages
|
82 |
|
|
; and: http://nsis.sourceforge.net/Docs/InstallOptions/Readme.html
|
83 |
|
|
!insertmacro MUI_HEADER_TEXT "VpnDial Einstellungen" "Bitte füllen Sie folgende Angaben aus"
|
84 |
|
|
!insertmacro MUI_INSTALLOPTIONS_DISPLAY "vpndial_settings.ini"
|
85 |
|
|
FunctionEnd
|
86 |
|
|
|
87 |
|
|
Function SetupPage2
|
88 |
|
|
!insertmacro MUI_HEADER_TEXT "VpnDial Einstellungen" "Bitte füllen Sie folgende Angaben aus"
|
89 |
|
|
!insertmacro MUI_INSTALLOPTIONS_DISPLAY "vpndial_settings_net.ini"
|
90 |
|
|
FunctionEnd
|
91 |
|
|
|
92 |
|
|
Function SetupPage3
|
93 |
|
|
!insertmacro MUI_HEADER_TEXT "VpnDial Einstellungen" "Bitte füllen Sie folgende Angaben aus"
|
94 |
|
|
!insertmacro MUI_INSTALLOPTIONS_DISPLAY "vpndial_settings_cert.ini"
|
95 |
|
|
FunctionEnd
|
96 |
|
|
|
97 |
|
|
|
98 |
|
|
; --------------------------------
|
99 |
|
|
; The stuff to install
|
100 |
|
|
; --------------------------------
|
101 |
|
|
|
102 |
|
|
Section
|
103 |
|
|
|
104 |
|
|
;Get Parameter from vpndial_settings.ini
|
105 |
|
|
|
106 |
|
|
;Get Connectionname
|
107 |
|
|
!insertmacro MUI_INSTALLOPTIONS_READ $connectionname "vpndial_settings.ini" "Field 2" "State"
|
108 |
|
|
;MessageBox MB_OK $R1
|
109 |
|
|
;StrCpy $connectionname $R1
|
110 |
|
|
|
111 |
|
|
;Get Destination_host
|
112 |
|
|
!insertmacro MUI_INSTALLOPTIONS_READ $destination_host "vpndial_settings.ini" "Field 3" "State"
|
113 |
|
|
;MessageBox MB_OK $R2
|
114 |
|
|
;StrCpy $destination_host $R2
|
115 |
|
|
|
116 |
|
|
;Get Username
|
117 |
|
|
!insertmacro MUI_INSTALLOPTIONS_READ $username "vpndial_settings.ini" "Field 4" "State"
|
118 |
|
|
|
119 |
|
|
;Get Password
|
120 |
|
|
!insertmacro MUI_INSTALLOPTIONS_READ $userpass "vpndial_settings.ini" "Field 8" "State"
|
121 |
|
|
|
122 |
|
|
;-------------------------------------------------------------------------------------------------------------
|
123 |
|
|
|
124 |
|
|
;Get Parameter from vpndial_settings_net.ini
|
125 |
|
|
|
126 |
|
|
;Get Destination_net
|
127 |
|
|
!insertmacro MUI_INSTALLOPTIONS_READ $R1 "vpndial_settings_net.ini" "Field 2" "State"
|
128 |
|
|
!insertmacro MUI_INSTALLOPTIONS_READ $R2 "vpndial_settings_net.ini" "Field 3" "State"
|
129 |
|
|
!insertmacro MUI_INSTALLOPTIONS_READ $R3 "vpndial_settings_net.ini" "Field 4" "State"
|
130 |
|
|
!insertmacro MUI_INSTALLOPTIONS_READ $R4 "vpndial_settings_net.ini" "Field 7" "State"
|
131 |
|
|
|
132 |
|
|
StrCpy $destination_net "$R1.$R2.$R3.$R4"
|
133 |
|
|
|
134 |
|
|
;Get Destination_mask
|
135 |
|
|
!insertmacro MUI_INSTALLOPTIONS_READ $R5 "vpndial_settings_net.ini" "Field 12" "State"
|
136 |
|
|
!insertmacro MUI_INSTALLOPTIONS_READ $R6 "vpndial_settings_net.ini" "Field 13" "State"
|
137 |
|
|
!insertmacro MUI_INSTALLOPTIONS_READ $R7 "vpndial_settings_net.ini" "Field 14" "State"
|
138 |
|
|
!insertmacro MUI_INSTALLOPTIONS_READ $R8 "vpndial_settings_net.ini" "Field 15" "State"
|
139 |
|
|
|
140 |
|
|
StrCpy $destination_mask "$R12.$R13.$R14.$R15"
|
141 |
|
|
|
142 |
|
|
;--------------------------------------------------------------------------------------------------------------
|
143 |
|
|
|
144 |
|
|
;Get Parameter from vpndial_settings_cert.ini
|
145 |
|
|
|
146 |
|
|
!insertmacro MUI_INSTALLOPTIONS_READ $cacert "vpndial_settings_cert.ini" "Field 2" "State"
|
147 |
|
|
!insertmacro MUI_INSTALLOPTIONS_READ $usercert "vpndial_settings_cert.ini" "Field 3" "State"
|
148 |
|
|
|
149 |
|
|
SectionEnd
|
150 |
|
|
|
151 |
|
|
Section
|
152 |
|
|
SetShellVarContext all
|
153 |
|
|
Push $APPDATA\Microsoft\Network\Connections\Pbk\rasphone.pbk
|
154 |
|
|
Push "[$connectionname]"
|
155 |
|
|
Call FileSearch
|
156 |
|
|
Pop $0 #Number of times found throughout
|
157 |
|
|
Pop $1 #Found at all? yes/no
|
158 |
|
|
Pop $2 #Number of lines found in
|
159 |
|
|
StrCmp $1 yes 0 +3
|
160 |
|
|
MessageBox MB_OK "Die Verbindung $\"$connectionname$\" existiert bereits. Der Eintrag kann leider nicht doppelt angelegt werden."
|
161 |
|
|
Abort
|
162 |
|
|
SectionEnd
|
163 |
|
|
|
164 |
|
|
Section "VpnDial" IDX_VpnDial
|
165 |
|
|
|
166 |
|
|
SetOverwrite on
|
167 |
|
|
|
168 |
|
|
SetDetailsPrint both
|
169 |
|
|
DetailPrint "Installiere VpnDial..."
|
170 |
|
|
|
171 |
|
|
;SectionIn RO
|
172 |
|
|
|
173 |
|
|
; Set output path to the installation directory.
|
174 |
|
|
SetOutPath $INSTDIR
|
175 |
|
|
|
176 |
|
|
;CreateDirectory $INSTDIR\certs\
|
177 |
|
|
|
178 |
|
|
; Put file there
|
179 |
|
|
File /r "vpndial\*.*"
|
180 |
|
|
|
181 |
|
|
; Write the installation path into the registry
|
182 |
|
|
WriteRegStr HKLM Software\NSIS_VpnDial "Install_Dir" "$INSTDIR"
|
183 |
|
|
|
184 |
|
|
; Write the uninstall keys for Windows
|
185 |
|
|
WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\VpnDial" "DisplayName" "VpnDial"
|
186 |
|
|
WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\VpnDial" "UninstallString" '"$INSTDIR\uninstall.exe"'
|
187 |
|
|
WriteRegDWORD HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\VpnDial" "NoModify" 1
|
188 |
|
|
WriteRegDWORD HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\VpnDial" "NoRepair" 1
|
189 |
|
|
WriteUninstaller "uninstall.exe"
|
190 |
|
|
|
191 |
|
|
SectionEnd
|
192 |
|
|
|
193 |
|
|
|
194 |
|
|
; ---------------------------------------------------------------------------
|
195 |
|
|
; pbk-Datei anpassen
|
196 |
|
|
; ---------------------------------------------------------------------------
|
197 |
|
|
|
198 |
|
|
; Verbindungsname
|
199 |
|
|
Section
|
200 |
|
|
DetailPrint "Installiere VPN-Verbindung..."
|
201 |
|
|
Push "[##connectionname##]" #-- text to be replaced within the " "
|
202 |
|
|
Push "[$connectionname]" #-- replace with anything within the " "
|
203 |
|
|
Push all #-- replace all occurrences
|
204 |
|
|
Push all #-- replace all occurrences
|
205 |
|
|
Push "$INSTDIR\pbk\connection.pbk" #-- file to replace in
|
206 |
|
|
Call AdvReplaceInFile #-- Call the Function
|
207 |
|
|
SectionEnd
|
208 |
|
|
|
209 |
|
|
; Gegenstelle
|
210 |
|
|
Section
|
211 |
|
|
Push "PhoneNumber=##destinationhost##" #-- text to be replaced within the " "
|
212 |
|
|
Push "PhoneNumber=$destination_host" #-- replace with anything within the " "
|
213 |
|
|
Push all #-- replace all occurrences
|
214 |
|
|
Push all #-- replace all occurrences
|
215 |
|
|
Push "$INSTDIR\pbk\connection.pbk" #-- file to replace in
|
216 |
|
|
Call AdvReplaceInFile #-- Call the Function
|
217 |
|
|
SectionEnd
|
218 |
|
|
|
219 |
|
|
; GUID
|
220 |
|
|
Section
|
221 |
|
|
Call CreateRasGUID
|
222 |
|
|
Pop $0 ; contains GUID
|
223 |
|
|
Push "Guid=##guid##" #-- text to be replaced within the " "
|
224 |
|
|
Push "Guid=$0" #-- replace with anything within the " "
|
225 |
|
|
Push all #-- replace all occurrences
|
226 |
|
|
Push all #-- replace all occurrences
|
227 |
|
|
Push "$INSTDIR\pbk\connection.pbk" #-- file to replace in
|
228 |
|
|
Call AdvReplaceInFile #-- Call the Function
|
229 |
|
|
SectionEnd
|
230 |
|
|
|
231 |
|
|
; Verbindungsdatei mit globaler Datei zusammenführen
|
232 |
|
|
Section
|
233 |
|
|
SetShellVarContext all
|
234 |
|
|
Push $INSTDIR\pbk\rasphone.pbk
|
235 |
|
|
Push $APPDATA\Microsoft\Network\Connections\Pbk\rasphone.pbk
|
236 |
|
|
Push $INSTDIR\pbk\connection.pbk
|
237 |
|
|
Call JoinFiles
|
238 |
|
|
CopyFiles $APPDATA\Microsoft\Network\Connections\Pbk\rasphone.pbk $INSTDIR\pbk\rasphone_orig.pbk
|
239 |
|
|
CopyFiles $INSTDIR\pbk\rasphone.pbk $APPDATA\Microsoft\Network\Connections\Pbk\rasphone.pbk
|
240 |
|
|
SetShellVarContext current
|
241 |
|
|
SectionEnd
|
242 |
|
|
|
243 |
|
|
Section
|
244 |
|
|
nsExec::Exec "$INSTDIR\bin\VpnDial.exe --setup $connectionname --user $username --pass $userpass"
|
245 |
|
|
SectionEnd
|
246 |
|
|
|
247 |
|
|
Section
|
248 |
|
|
;nsExec::Exec "$INSTDIR\bin\certmgr.exe -add -c $INSTDIR\certs\$cacert -s -r localMachine root"
|
249 |
|
|
;nsExec::Exec "$INSTDIR\bin\certmgr.exe -add -c $cacert -s -r localMachine root"
|
250 |
|
|
SectionEnd
|
251 |
|
|
|
252 |
|
|
Section
|
253 |
|
|
;nsExec::Exec "$INSTDIR\bin\winhttpcertcfg.exe -g -i $INSTDIR\certs\$usercert -c LOCAL_MACHINE\My -a $currentuser"
|
254 |
|
|
nsExec::Exec "$INSTDIR\bin\winhttpcertcfg.exe -g -i $usercert -c LOCAL_MACHINE\My -a $currentuser"
|
255 |
|
|
SectionEnd
|
256 |
|
|
|
257 |
|
|
; Optional section (can be disabled by the user)
|
258 |
|
|
Section "Startmenü-Einträge" IDX_STARTMENU
|
259 |
|
|
|
260 |
|
|
SetDetailsPrint both
|
261 |
|
|
DetailPrint "Installiere Startmenü-Einträge und Desktop-Verknüpfungen..."
|
262 |
|
|
|
263 |
|
|
CreateDirectory "$SMPROGRAMS\VpnDial"
|
264 |
|
|
CreateShortCut "$SMPROGRAMS\VpnDial\Uninstall.lnk" "$INSTDIR\uninstall.exe" "" "$INSTDIR\uninstall.exe" 0
|
265 |
|
|
CreateShortCut "$SMPROGRAMS\VpnDial\VpnMonitor.lnk" "$INSTDIR\bin\VpnDial.exe" "--gui --up --monitor $connectionname --net $destination_net" "$INSTDIR\bin\VpnDial.exe" 0
|
266 |
|
|
CreateShortCut "$SMPROGRAMS\VpnDial\VpnDial.lnk" "$INSTDIR\bin\VpnDial.exe" "--dial $connectionname --net $destination_net" "$INSTDIR\bin\VpnDial.exe" 0
|
267 |
|
|
;CreateShortCut "$SMPROGRAMS\VpnDial\VpnSetup.lnk" "$INSTDIR\bin\VpnDial.exe" "--setup $connectionname --user $username --pass $userpass" "$INSTDIR\bin\VpnDial.exe" 0
|
268 |
|
|
CreateShortCut "$SMPROGRAMS\VpnDial\Zertifikate.lnk" "$INSTDIR\certs\" "" "$INSTDIR\certs\" 0
|
269 |
|
|
CreateShortCut "$SMPROGRAMS\VpnDial\ZertifikatsVerwaltung.lnk" "$INSTDIR\links\IPSec.msc" "" "$INSTDIR\links\IPSec.msc" 0
|
270 |
|
|
;CreateShortCut "$SMPROGRAMS\VpnDial\README.lnk" "$INSTDIR\doc\README.txt" "" "$INSTDIR\doc\README.txt" 0
|
271 |
|
|
;CreateShortCut "$SMPROGRAMS\VpnDial\README-HTML.lnk" "$INSTDIR\doc\README.htm" "" "$INSTDIR\doc\README.htm" 0
|
272 |
|
|
|
273 |
|
|
CopyFiles "$INSTDIR\links\Netzwerkverbindung*" "$SMPROGRAMS\VpnDial\"
|
274 |
|
|
|
275 |
|
|
SectionEnd
|
276 |
|
|
|
277 |
|
|
|
278 |
|
|
; --------------------------------
|
279 |
|
|
; Uninstaller
|
280 |
|
|
; --------------------------------
|
281 |
|
|
|
282 |
|
|
Section "Uninstall" IDX_UNINSTALL
|
283 |
|
|
|
284 |
|
|
; ------------------
|
285 |
|
|
; uninstall VpnDial
|
286 |
|
|
; ------------------
|
287 |
|
|
|
288 |
|
|
; Remove registry keys
|
289 |
|
|
DeleteRegKey HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\VpnDial"
|
290 |
|
|
DeleteRegKey HKLM SOFTWARE\NSIS_VpnDial
|
291 |
|
|
|
292 |
|
|
;Remove files and uninstaller
|
293 |
|
|
;Delete $INSTDIR\makensisw.exe
|
294 |
|
|
;Delete $INSTDIR\uninstall.exe
|
295 |
|
|
;Delete "$INSTDIR\*.*"
|
296 |
|
|
|
297 |
|
|
; Remove shortcuts, if any
|
298 |
|
|
Delete "$SMPROGRAMS\VpnDial\*.*"
|
299 |
|
|
|
300 |
|
|
; Remove directories used
|
301 |
|
|
RMDir /r "$SMPROGRAMS\VpnDial"
|
302 |
|
|
RMDir /r "$INSTDIR"
|
303 |
|
|
|
304 |
|
|
SectionEnd
|