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

Legend:
Removed from v.1.2  
changed lines
  Added in v.1.10

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