/[cvs]/joko/ToolBox/Windows/VpnDial-installer/vpn.nsi
ViewVC logotype

Diff of /joko/ToolBox/Windows/VpnDial-installer/vpn.nsi

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1.1 by joko, Fri Nov 18 19:44:44 2005 UTC revision 1.8 by joko, Tue Nov 22 16:39:50 2005 UTC
# Line 1  Line 1 
1  ; VpnDial.nsi  ; VpnDial.nsi
2  ; $Id$  ; $Id$
3  ;  ;
4  ; This script can install VpnDial,  ; This script can install VpnDial,
5  ; has uninstall support and (optionally) installs start menu shortcuts.  ; has uninstall support and (optionally) installs start menu shortcuts.
6  ;  ;
7    
8  !include "connection.nsi"  !include "MUI.nsh"
9  !include "vpn_functions.nsi"  !include "variables-declaration.nsi"
10    !include "string_functions.nsi"
11    !include "file_functions.nsi"
12  ; --------------------------------  !include "ras_functions.nsi"
13  ;   The name of the installer  
14  ; --------------------------------  
15  Name "VpnDial"  ; --------------------------------
16    ;   The name of the installer
17  ; The file to write  ; --------------------------------
18  OutFile "VpnDial-Setup.exe"  Name "VpnDial"
19    
20  ; The default installation directory  ; The file to write
21  InstallDir $PROGRAMFILES\NetFragOrg\VpnDial  OutFile "VpnDial-Setup.exe"
22    
23  ; Registry key to check for directory (so if you install again, it will  ; The default installation directory
24  ; overwrite the old one automatically)  InstallDir $PROGRAMFILES\NetFragOrg\VpnDial
25  InstallDirRegKey HKLM "Software\NSIS_VpnDial" "Install_Dir"  
26    ; Registry key to check for directory (so if you install again, it will
27  ; more options: language of the installer & installer style  ; overwrite the old one automatically)
28  LoadLanguageFile "${NSISDIR}\Contrib\Language files\German.nlf"  InstallDirRegKey HKLM "Software\NSIS_VpnDial" "Install_Dir"
29  XPStyle on  
30    SetOverwrite on
31    
32  ; --------------------------------  
33  ;   Pages  ; --------------------------------
34  ; --------------------------------  ; (MUI) Interface Settings
35    ; --------------------------------
36  Page components  !define MUI_ABORTWARNING
37  Page directory  !define MUI_COMPONENTSPAGE_NODESC
38  Page instfiles  !define MUI_ICON "key.ico"
39    !define MUI_UNICON "key.ico"
40  UninstPage uninstConfirm  
41  UninstPage instfiles  
42    ; --------------------------------
43  ; --------------------------------  ;   Pages
44  ;   The stuff to install  ; --------------------------------
45  ; --------------------------------  
46    UninstPage uninstConfirm
47  Section  UninstPage instfiles
48    SetShellVarContext all  
49    Push $APPDATA\Microsoft\Network\Connections\Pbk\rasphone.pbk  !insertmacro MUI_PAGE_WELCOME
50    Push "[$connectionname]"  Page custom SetupPage1
51     Call FileSearch  Page custom SetupPage2
52    Pop $0 #Number of times found throughout  Page custom SetupPage3
53    Pop $1 #Found at all? yes/no  !insertmacro MUI_PAGE_COMPONENTS
54    Pop $2 #Number of lines found in  !insertmacro MUI_PAGE_DIRECTORY
55    StrCmp $1 yes 0 +3  !insertmacro MUI_PAGE_INSTFILES
56    MessageBox MB_OK "$\"[$connectionname]$\" was found already found. Cannot create. Sorry."  
57    Abort  !insertmacro MUI_UNPAGE_CONFIRM
58  SectionEnd  !insertmacro MUI_UNPAGE_INSTFILES
59    !insertmacro MUI_LANGUAGE "German"
60  Section "VpnDial" IDX_VpnDial  
61    
62    SetDetailsPrint both  ; --------------------------------
63    DetailPrint "Installiere VpnDial..."  ; .onInit
64    ; --------------------------------
65    ;SectionIn RO  
66      Function .onInit
67    ; Set output path to the installation directory.  
68    SetOutPath $INSTDIR  
69      System::Call 'kernel32::CreateMutexA(i 0, i 0, t "myMutex") i .r1 ?e'
70    ;CreateDirectory $INSTDIR\certs\    Pop $R0
71      StrCmp $R0 0 +3
72    ; Put file there      MessageBox MB_OK|MB_ICONEXCLAMATION "Die Installation läuft bereits."
73    ;File /r "C:\IPSec\nsis\vpndial\*.*"      Abort
74    File /r "vpndial\*.*"  
75    ;File "C:\IPSec\nsis\vpndial\certs\"    !insertmacro MUI_INSTALLOPTIONS_EXTRACT "vpndial_settings.ini"
76    ;File "C:\IPSec\nsis\vpndial\certs\*.*"    !insertmacro MUI_INSTALLOPTIONS_EXTRACT "vpndial_settings_net.ini"  
77        !insertmacro MUI_INSTALLOPTIONS_EXTRACT "vpndial_settings_cert.ini"
78    ; Write the installation path into the registry  FunctionEnd
79    WriteRegStr HKLM Software\NSIS_VpnDial "Install_Dir" "$INSTDIR"  
80      Function SetupPage1
81    ; Write the uninstall keys for Windows    ; custom page
82    WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\VpnDial" "DisplayName" "VpnDial"    ; see: http://nsis.sourceforge.net/Docs/Modern%20UI/Readme.html#customPages
83    WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\VpnDial" "UninstallString" '"$INSTDIR\uninstall.exe"'    ; and: http://nsis.sourceforge.net/Docs/InstallOptions/Readme.html
84    WriteRegDWORD HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\VpnDial" "NoModify" 1    !insertmacro MUI_HEADER_TEXT "VpnDial Einstellungen" "Bitte füllen Sie folgende Angaben aus"
85    WriteRegDWORD HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\VpnDial" "NoRepair" 1    !insertmacro MUI_INSTALLOPTIONS_DISPLAY "vpndial_settings.ini"  
86    WriteUninstaller "uninstall.exe"  FunctionEnd
87    
88  SectionEnd  Function SetupPage2
89      !insertmacro MUI_HEADER_TEXT "VpnDial Einstellungen" "Bitte füllen Sie folgende Angaben aus"
90  Section    !insertmacro MUI_INSTALLOPTIONS_DISPLAY "vpndial_settings_net.ini"
91    DetailPrint "Installiere VPN-Verbindung..."  FunctionEnd
92    Push "[##connectionname##]"            #-- text to be replaced  within the " "  
93    Push "[$connectionname]"             #-- replace with anything within the " "  Function SetupPage3
94    Push all                      #-- replace all occurrences    !insertmacro MUI_HEADER_TEXT "VpnDial Einstellungen" "Bitte füllen Sie folgende Angaben aus"
95    Push all                      #-- replace all occurrences    !insertmacro MUI_INSTALLOPTIONS_DISPLAY "vpndial_settings_cert.ini"
96    Push "$INSTDIR\pbk\connection.pbk"      #-- file to replace in  FunctionEnd
97    Call AdvReplaceInFile         #-- Call the Function  
98  SectionEnd  
99    ; --------------------------------
100  Section  ;   The stuff to install
101    Push "PhoneNumber=##destinationhost##"            #-- text to be replaced  within the " "  ; --------------------------------
102    Push "PhoneNumber=$destination_host"             #-- replace with anything within the " "  
103    Push all                      #-- replace all occurrences  Section
104    Push all                      #-- replace all occurrences      
105    Push "$INSTDIR\pbk\connection.pbk"      #-- file to replace in      ;Get Parameter from vpndial_settings.ini
106    Call AdvReplaceInFile         #-- Call the Function      
107  SectionEnd      ;Get Connectionname  
108        !insertmacro MUI_INSTALLOPTIONS_READ $connectionname "vpndial_settings.ini" "Field 2" "State"
109  Section      ;MessageBox MB_OK $R1
110    SetShellVarContext all      ;StrCpy $connectionname $R1
111      Push $INSTDIR\pbk\rasphone.pbk  
112      Push $APPDATA\Microsoft\Network\Connections\Pbk\rasphone.pbk      ;Get Destination_host
113      Push $INSTDIR\pbk\connection.pbk      !insertmacro MUI_INSTALLOPTIONS_READ $destination_host "vpndial_settings.ini" "Field 3" "State"
114      Call JoinFiles              ;MessageBox MB_OK $R2
115      CopyFiles $APPDATA\Microsoft\Network\Connections\Pbk\rasphone.pbk $INSTDIR\pbk\rasphone_orig.pbk      ;StrCpy $destination_host $R2
116      CopyFiles $INSTDIR\pbk\rasphone.pbk $APPDATA\Microsoft\Network\Connections\Pbk\rasphone.pbk  
117    SetShellVarContext current      ;Get Username
118  SectionEnd      !insertmacro MUI_INSTALLOPTIONS_READ $username "vpndial_settings.ini" "Field 4" "State"
119    
120  Section      ;Get Password
121  nsExec::Exec "$INSTDIR\bin\VpnDial.exe --setup $connectionname --user $username --pass $userpass"      !insertmacro MUI_INSTALLOPTIONS_READ $userpass "vpndial_settings.ini" "Field 8" "State"
122  SectionEnd  
123        ;-------------------------------------------------------------------------------------------------------------
124  Section  
125  nsExec::Exec "$INSTDIR\bin\certmgr.exe -add -c $INSTDIR\certs\$cacert -s -r localMachine root"      ;Get Parameter from vpndial_settings_net.ini
126  SectionEnd      
127        ;Get Destination_net
128  Section      !insertmacro MUI_INSTALLOPTIONS_READ $R1 "vpndial_settings_net.ini" "Field 2" "State"
129  nsExec::Exec "$INSTDIR\bin\winhttpcertcfg.exe  -g -i $INSTDIR\certs\$usercert -c LOCAL_MACHINE\My -a $currentuser"      !insertmacro MUI_INSTALLOPTIONS_READ $R2 "vpndial_settings_net.ini" "Field 3" "State"  
130  SectionEnd      !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  ; Optional section (can be disabled by the user)  
133  Section "Start Menu Shortcuts" IDX_STARTMENU      StrCpy $destination_net "$R1.$R2.$R3.$R4"
134        
135    SetDetailsPrint both      ;Get Destination_mask
136    DetailPrint "Installiere Startmenü-Einträge und Desktop-Verknüpfungen..."      !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    CreateDirectory "$SMPROGRAMS\VpnDial"      !insertmacro MUI_INSTALLOPTIONS_READ $R7 "vpndial_settings_net.ini" "Field 14" "State"
139    CreateShortCut "$SMPROGRAMS\VpnDial\Uninstall.lnk" "$INSTDIR\uninstall.exe" "" "$INSTDIR\uninstall.exe" 0      !insertmacro MUI_INSTALLOPTIONS_READ $R8 "vpndial_settings_net.ini" "Field 15" "State"
140    CreateShortCut "$SMPROGRAMS\VpnDial\VpnMonitor.lnk" "$INSTDIR\bin\VpnDial.exe" "--gui --up --monitor $connectionname --net $destination_net" "$INSTDIR\bin\VpnDial.exe" 0  
141    CreateShortCut "$SMPROGRAMS\VpnDial\VpnDial.lnk" "$INSTDIR\bin\VpnDial.exe" "--dial $connectionname --net $destination_net" "$INSTDIR\bin\VpnDial.exe" 0      StrCpy  $destination_mask "$R12.$R13.$R14.$R15"
142    ;CreateShortCut "$SMPROGRAMS\VpnDial\VpnSetup.lnk" "$INSTDIR\bin\VpnDial.exe" "--setup $connectionname --user $username --pass $userpass" "$INSTDIR\bin\VpnDial.exe" 0  
143    CreateShortCut "$SMPROGRAMS\VpnDial\Zertifikate.lnk" "$INSTDIR\certs\" "" "$INSTDIR\certs\" 0      ;--------------------------------------------------------------------------------------------------------------
144    CreateShortCut "$SMPROGRAMS\VpnDial\ZertifikatsVerwaltung.lnk" "$INSTDIR\links\IPSec.msc" "" "$INSTDIR\links\IPSec.msc" 0  
145    CreateShortCut "$SMPROGRAMS\VpnDial\README.lnk" "$INSTDIR\doc\README.txt" "" "$INSTDIR\doc\README.txt" 0      ;Get Parameter from vpndial_settings_cert.ini
146    CreateShortCut "$SMPROGRAMS\VpnDial\README-HTML.lnk" "$INSTDIR\doc\README.htm" "" "$INSTDIR\doc\README.htm" 0  
147        !insertmacro MUI_INSTALLOPTIONS_READ $cacert "vpndial_settings_cert.ini" "Field 2" "State"
148    CopyFiles "$INSTDIR\links\Netzwerkverbindung*" "$SMPROGRAMS\VpnDial\"      !insertmacro MUI_INSTALLOPTIONS_READ $usercert "vpndial_settings_cert.ini" "Field 3" "State"
149    
150  SectionEnd  SectionEnd
151    
152    Section
153      SetShellVarContext all
154  ; --------------------------------    Push $APPDATA\Microsoft\Network\Connections\Pbk\rasphone.pbk
155  ;   Uninstaller    Push "[$connectionname]"
156  ; --------------------------------     Call FileSearch
157      Pop $0 #Number of times found throughout
158  Section "Uninstall" IDX_UNINSTALL    Pop $1 #Found at all? yes/no
159      Pop $2 #Number of lines found in
160    ; ------------------    StrCmp $1 yes 0 +3
161    ;   uninstall VpnDial    MessageBox MB_OK "Die Verbindung $\"$connectionname$\" existiert bereits. Der Eintrag kann leider nicht doppelt angelegt werden."
162    ; ------------------    Abort
163    SectionEnd
164    ; Remove registry keys  
165    DeleteRegKey HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\VpnDial"  Section "VpnDial" IDX_VpnDial
166    DeleteRegKey HKLM SOFTWARE\NSIS_VpnDial  
167      SetOverwrite on
168    ;Remove files and uninstaller      
169    ;Delete $INSTDIR\makensisw.exe    SetDetailsPrint both
170    ;Delete $INSTDIR\uninstall.exe    DetailPrint "Installiere VpnDial..."
171    ;Delete "$INSTDIR\*.*"  
172          ;SectionIn RO
173    ; Remove shortcuts, if any    
174    Delete "$SMPROGRAMS\VpnDial\*.*"    ; Set output path to the installation directory.
175      SetOutPath $INSTDIR
176    ; Remove directories used  
177    RMDir /r "$SMPROGRAMS\VpnDial"    ;CreateDirectory $INSTDIR\certs\
178    RMDir /r "$INSTDIR"  
179      ; Put file there
180  SectionEnd    File /r "vpndial\*.*"
181        
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    ;nsExec::Exec "$INSTDIR\bin\certmgr.exe -add -c $cacert -s -r localMachine root"
262    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      CreateShortCut "$SMPROGRAMS\VpnDial\VpnMonitor.lnk" "$INSTDIR\bin\VpnDial.exe" "--gui --up --monitor $connectionname --net $destination_net" "$INSTDIR\bin\VpnDial.exe" 0
278      CreateShortCut "$SMPROGRAMS\VpnDial\VpnDial.lnk" "$INSTDIR\bin\VpnDial.exe" "--dial $connectionname --net $destination_net" "$INSTDIR\bin\VpnDial.exe" 0
279      ;CreateShortCut "$SMPROGRAMS\VpnDial\VpnSetup.lnk" "$INSTDIR\bin\VpnDial.exe" "--setup $connectionname --user $username --pass $userpass" "$INSTDIR\bin\VpnDial.exe" 0
280      CreateShortCut "$SMPROGRAMS\VpnDial\Zertifikate.lnk" "$INSTDIR\certs\" "" "$INSTDIR\certs\" 0
281      CreateShortCut "$SMPROGRAMS\VpnDial\ZertifikatsVerwaltung.lnk" "$INSTDIR\links\IPSec.msc" "" "$INSTDIR\links\IPSec.msc" 0
282      ;CreateShortCut "$SMPROGRAMS\VpnDial\README.lnk" "$INSTDIR\doc\README.txt" "" "$INSTDIR\doc\README.txt" 0
283      ;CreateShortCut "$SMPROGRAMS\VpnDial\README-HTML.lnk" "$INSTDIR\doc\README.htm" "" "$INSTDIR\doc\README.htm" 0
284    
285      CopyFiles "$INSTDIR\links\Netzwerkverbindung*" "$SMPROGRAMS\VpnDial\"
286    
287    SectionEnd
288    
289    
290    ; --------------------------------
291    ;   Uninstaller
292    ; --------------------------------
293    
294    Section "Uninstall" IDX_UNINSTALL
295    
296      ; ------------------
297      ;   uninstall VpnDial
298      ; ------------------
299    
300      ; Remove registry keys
301      DeleteRegKey HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\VpnDial"
302      DeleteRegKey HKLM SOFTWARE\NSIS_VpnDial
303    
304      ;Remove files and uninstaller
305      ;Delete $INSTDIR\makensisw.exe
306      ;Delete $INSTDIR\uninstall.exe
307      ;Delete "$INSTDIR\*.*"
308        
309      ; Remove shortcuts, if any
310      Delete "$SMPROGRAMS\VpnDial\*.*"
311    
312      ; Remove directories used
313      RMDir /r "$SMPROGRAMS\VpnDial"
314      RMDir /r "$INSTDIR"
315    
316    SectionEnd

Legend:
Removed from v.1.1  
changed lines
  Added in v.1.8

MailToCvsAdmin">MailToCvsAdmin
ViewVC Help
Powered by ViewVC 1.1.26 RSS 2.0 feed