/[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.3 by joko, Mon Nov 21 21:45:29 2005 UTC revision 1.12 by janosch, Tue Nov 22 17:35:04 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_WELCOME  !insertmacro MUI_PAGE_INSTFILES
56  Page custom Setup  
57  !insertmacro MUI_PAGE_COMPONENTS  !insertmacro MUI_UNPAGE_CONFIRM
58  !insertmacro MUI_PAGE_DIRECTORY  !insertmacro MUI_UNPAGE_INSTFILES
59  !insertmacro MUI_PAGE_INSTFILES  !insertmacro MUI_LANGUAGE "German"
60    
61  !insertmacro MUI_UNPAGE_CONFIRM  
62  !insertmacro MUI_UNPAGE_INSTFILES  ; --------------------------------
63  !insertmacro MUI_LANGUAGE "German"  ; .onInit
64    ; --------------------------------
65    
66  ; --------------------------------  Function .onInit
67  ; .onInit  
68  ; --------------------------------  
69      System::Call 'kernel32::CreateMutexA(i 0, i 0, t "myMutex") i .r1 ?e'
70  Function .onInit    Pop $R0
71      StrCmp $R0 0 +3
72    System::Call 'kernel32::CreateMutexA(i 0, i 0, t "myMutex") i .r1 ?e'      MessageBox MB_OK|MB_ICONEXCLAMATION "Die Installation läuft bereits."
73    Pop $R0      Abort
74    StrCmp $R0 0 +3  
75      MessageBox MB_OK|MB_ICONEXCLAMATION "Die Installation läuft bereits."    !insertmacro MUI_INSTALLOPTIONS_EXTRACT "vpndial_settings.ini"
76      Abort    !insertmacro MUI_INSTALLOPTIONS_EXTRACT "vpndial_settings_net.ini"  
77      !insertmacro MUI_INSTALLOPTIONS_EXTRACT "vpndial_settings_cert.ini"
78    !insertmacro MUI_INSTALLOPTIONS_EXTRACT "vpndial_settings.ini"  FunctionEnd
79    
80  FunctionEnd  Function SetupPage1
81      ; custom page
82  Function Setup    ; see: http://nsis.sourceforge.net/Docs/Modern%20UI/Readme.html#customPages
83    ; custom page    ; and: http://nsis.sourceforge.net/Docs/InstallOptions/Readme.html
84    ; see: http://nsis.sourceforge.net/Docs/Modern%20UI/Readme.html#customPages    !insertmacro MUI_HEADER_TEXT "VpnDial Einstellungen" "Bitte füllen Sie folgende Angaben aus"
85    ; and: http://nsis.sourceforge.net/Docs/InstallOptions/Readme.html    !insertmacro MUI_INSTALLOPTIONS_DISPLAY "vpndial_settings.ini"  
86    !insertmacro MUI_HEADER_TEXT "VpnDial Einstellungen" "Bitte füllen Sie folgende Angaben aus"  FunctionEnd
87    !insertmacro MUI_INSTALLOPTIONS_DISPLAY "vpndial_settings.ini"  
88  FunctionEnd  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  ;   The stuff to install  FunctionEnd
92  ; --------------------------------  
93    Function SetupPage3
94  Section    !insertmacro MUI_HEADER_TEXT "VpnDial Einstellungen" "Bitte füllen Sie folgende Angaben aus"
95    SetShellVarContext all    !insertmacro MUI_INSTALLOPTIONS_DISPLAY "vpndial_settings_cert.ini"
96    Push $APPDATA\Microsoft\Network\Connections\Pbk\rasphone.pbk  FunctionEnd
97    Push "[$connectionname]"  
98     Call FileSearch  
99    Pop $0 #Number of times found throughout  ; --------------------------------
100    Pop $1 #Found at all? yes/no  ;   The stuff to install
101    Pop $2 #Number of lines found in  ; --------------------------------
102    StrCmp $1 yes 0 +3  
103    MessageBox MB_OK "Die Verbindung $\"$connectionname$\" existiert bereits. Der Eintrag kann leider nicht doppelt angelegt werden."  Section
104    Abort      
105  SectionEnd      ;Get Parameter from vpndial_settings.ini
106        
107  Section "VpnDial" IDX_VpnDial      ;Get Connectionname  
108        !insertmacro MUI_INSTALLOPTIONS_READ $connectionname "vpndial_settings.ini" "Field 2" "State"
109    SetOverwrite on      ;MessageBox MB_OK $R1
110            ;StrCpy $connectionname $R1
111    SetDetailsPrint both  
112    DetailPrint "Installiere VpnDial..."      ;Get Destination_host
113        !insertmacro MUI_INSTALLOPTIONS_READ $destination_host "vpndial_settings.ini" "Field 3" "State"
114    ;SectionIn RO      ;MessageBox MB_OK $R2
115          ;StrCpy $destination_host $R2
116    ; Set output path to the installation directory.  
117    SetOutPath $INSTDIR      ;Get Username
118        !insertmacro MUI_INSTALLOPTIONS_READ $username "vpndial_settings.ini" "Field 4" "State"
119    ;CreateDirectory $INSTDIR\certs\  
120        ;Get Password
121    ; Put file there      !insertmacro MUI_INSTALLOPTIONS_READ $userpass "vpndial_settings.ini" "Field 8" "State"
122    File /r "vpndial\*.*"  
123            ;-------------------------------------------------------------------------------------------------------------
124    ; Write the installation path into the registry  
125    WriteRegStr HKLM Software\NSIS_VpnDial "Install_Dir" "$INSTDIR"      ;Get Parameter from vpndial_settings_net.ini
126          
127    ; Write the uninstall keys for Windows      ;Get Destination_net
128    WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\VpnDial" "DisplayName" "VpnDial"      !insertmacro MUI_INSTALLOPTIONS_READ $R1 "vpndial_settings_net.ini" "Field 2" "State"
129    WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\VpnDial" "UninstallString" '"$INSTDIR\uninstall.exe"'      !insertmacro MUI_INSTALLOPTIONS_READ $R2 "vpndial_settings_net.ini" "Field 3" "State"  
130    WriteRegDWORD HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\VpnDial" "NoModify" 1      !insertmacro MUI_INSTALLOPTIONS_READ $R3 "vpndial_settings_net.ini" "Field 4" "State"
131    WriteRegDWORD HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\VpnDial" "NoRepair" 1      !insertmacro MUI_INSTALLOPTIONS_READ $R4 "vpndial_settings_net.ini" "Field 7" "State"
132    WriteUninstaller "uninstall.exe"  
133        StrCpy $destination_net "$R1.$R2.$R3.$R4"
134  SectionEnd      
135        ;Get Destination_mask
136  Section      !insertmacro MUI_INSTALLOPTIONS_READ $R5 "vpndial_settings_net.ini" "Field 12" "State"
137    DetailPrint "Installiere VPN-Verbindung..."      !insertmacro MUI_INSTALLOPTIONS_READ $R6 "vpndial_settings_net.ini" "Field 13" "State"  
138    Push "[##connectionname##]"            #-- text to be replaced  within the " "      !insertmacro MUI_INSTALLOPTIONS_READ $R7 "vpndial_settings_net.ini" "Field 14" "State"
139    Push "[$connectionname]"             #-- replace with anything within the " "      !insertmacro MUI_INSTALLOPTIONS_READ $R8 "vpndial_settings_net.ini" "Field 15" "State"
140    Push all                      #-- replace all occurrences  
141    Push all                      #-- replace all occurrences      StrCpy  $destination_mask "$R12.$R13.$R14.$R15"
142    Push "$INSTDIR\pbk\connection.pbk"      #-- file to replace in  
143    Call AdvReplaceInFile         #-- Call the Function      ;--------------------------------------------------------------------------------------------------------------
144  SectionEnd  
145        ;Get Parameter from vpndial_settings_cert.ini
146  Section  
147    Push "PhoneNumber=##destinationhost##"            #-- text to be replaced  within the " "      !insertmacro MUI_INSTALLOPTIONS_READ $cacert "vpndial_settings_cert.ini" "Field 2" "State"
148    Push "PhoneNumber=$destination_host"             #-- replace with anything within the " "      !insertmacro MUI_INSTALLOPTIONS_READ $usercert "vpndial_settings_cert.ini" "Field 3" "State"
149    Push all                      #-- replace all occurrences  
150    Push all                      #-- replace all occurrences  SectionEnd
151    Push "$INSTDIR\pbk\connection.pbk"      #-- file to replace in  
152    Call AdvReplaceInFile         #-- Call the Function  Section
153  SectionEnd    SetShellVarContext all
154      Push $APPDATA\Microsoft\Network\Connections\Pbk\rasphone.pbk
155  Section    Push "[$connectionname]"
156    SetShellVarContext all     Call FileSearch
157      Push $INSTDIR\pbk\rasphone.pbk    Pop $0 #Number of times found throughout
158      Push $APPDATA\Microsoft\Network\Connections\Pbk\rasphone.pbk    Pop $1 #Found at all? yes/no
159      Push $INSTDIR\pbk\connection.pbk    Pop $2 #Number of lines found in
160      Call JoinFiles            StrCmp $1 yes 0 +3
161      CopyFiles $APPDATA\Microsoft\Network\Connections\Pbk\rasphone.pbk $INSTDIR\pbk\rasphone_orig.pbk    MessageBox MB_OK "Die Verbindung $\"$connectionname$\" existiert bereits. Der Eintrag kann leider nicht doppelt angelegt werden."
162      CopyFiles $INSTDIR\pbk\rasphone.pbk $APPDATA\Microsoft\Network\Connections\Pbk\rasphone.pbk    Abort
163    SetShellVarContext current  SectionEnd
164  SectionEnd  
165    Section "VpnDial" IDX_VpnDial
166  Section  
167  nsExec::Exec "$INSTDIR\bin\VpnDial.exe --setup $connectionname --user $username --pass $userpass"    SetOverwrite on
168  SectionEnd      
169      SetDetailsPrint both
170  Section    DetailPrint "Installiere VpnDial..."
171  nsExec::Exec "$INSTDIR\bin\certmgr.exe -add -c $INSTDIR\certs\$cacert -s -r localMachine root"  
172  SectionEnd    ;SectionIn RO
173      
174  Section    ; Set output path to the installation directory.
175  nsExec::Exec "$INSTDIR\bin\winhttpcertcfg.exe  -g -i $INSTDIR\certs\$usercert -c LOCAL_MACHINE\My -a $currentuser"    SetOutPath $INSTDIR
176  SectionEnd  
177      ;CreateDirectory $INSTDIR\certs\
178  ; Optional section (can be disabled by the user)  
179  Section "Startmenü-Einträge" IDX_STARTMENU    ; Put file there
180      File /r /x CVS "vpndial\*.*"
181    SetDetailsPrint both      
182    DetailPrint "Installiere Startmenü-Einträge und Desktop-Verknüpfungen..."    ; Write the installation path into the registry
183      WriteRegStr HKLM Software\NSIS_VpnDial "Install_Dir" "$INSTDIR"
184    CreateDirectory "$SMPROGRAMS\VpnDial"    
185    CreateShortCut "$SMPROGRAMS\VpnDial\Uninstall.lnk" "$INSTDIR\uninstall.exe" "" "$INSTDIR\uninstall.exe" 0    ; Write the uninstall keys for Windows
186    CreateShortCut "$SMPROGRAMS\VpnDial\VpnMonitor.lnk" "$INSTDIR\bin\VpnDial.exe" "--gui --up --monitor $connectionname --net $destination_net" "$INSTDIR\bin\VpnDial.exe" 0    WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\VpnDial" "DisplayName" "VpnDial"
187    CreateShortCut "$SMPROGRAMS\VpnDial\VpnDial.lnk" "$INSTDIR\bin\VpnDial.exe" "--dial $connectionname --net $destination_net" "$INSTDIR\bin\VpnDial.exe" 0    WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\VpnDial" "UninstallString" '"$INSTDIR\uninstall.exe"'
188    ;CreateShortCut "$SMPROGRAMS\VpnDial\VpnSetup.lnk" "$INSTDIR\bin\VpnDial.exe" "--setup $connectionname --user $username --pass $userpass" "$INSTDIR\bin\VpnDial.exe" 0    WriteRegDWORD HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\VpnDial" "NoModify" 1
189    CreateShortCut "$SMPROGRAMS\VpnDial\Zertifikate.lnk" "$INSTDIR\certs\" "" "$INSTDIR\certs\" 0    WriteRegDWORD HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\VpnDial" "NoRepair" 1
190    CreateShortCut "$SMPROGRAMS\VpnDial\ZertifikatsVerwaltung.lnk" "$INSTDIR\links\IPSec.msc" "" "$INSTDIR\links\IPSec.msc" 0    WriteUninstaller "uninstall.exe"
191    ;CreateShortCut "$SMPROGRAMS\VpnDial\README.lnk" "$INSTDIR\doc\README.txt" "" "$INSTDIR\doc\README.txt" 0  
192    ;CreateShortCut "$SMPROGRAMS\VpnDial\README-HTML.lnk" "$INSTDIR\doc\README.htm" "" "$INSTDIR\doc\README.htm" 0  SectionEnd
193    
194    CopyFiles "$INSTDIR\links\Netzwerkverbindung*" "$SMPROGRAMS\VpnDial\"  
195    
196  SectionEnd  
197    ; ---------------------------------------------------------------------------
198    
199  ; --------------------------------  ;               pbk-Datei anpassen
200  ;   Uninstaller  
201  ; --------------------------------  ; ---------------------------------------------------------------------------
202    
203  Section "Uninstall" IDX_UNINSTALL  
204    
205    ; ------------------  ; Verbindungsname
206    ;   uninstall VpnDial  Section
207    ; ------------------    DetailPrint "Installiere VPN-Verbindung..."
208      Push "[##connectionname##]"            #-- text to be replaced  within the " "
209    ; Remove registry keys    Push "[$connectionname]"             #-- replace with anything within the " "
210    DeleteRegKey HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\VpnDial"    Push all                      #-- replace all occurrences
211    DeleteRegKey HKLM SOFTWARE\NSIS_VpnDial    Push all                      #-- replace all occurrences
212      Push "$INSTDIR\pbk\connection.pbk"      #-- file to replace in
213    ;Remove files and uninstaller    Call AdvReplaceInFile         #-- Call the Function
214    ;Delete $INSTDIR\makensisw.exe  SectionEnd
215    ;Delete $INSTDIR\uninstall.exe  
216    ;Delete "$INSTDIR\*.*"  ; Gegenstelle
217        Section
218    ; Remove shortcuts, if any    Push "PhoneNumber=##destinationhost##"            #-- text to be replaced  within the " "
219    Delete "$SMPROGRAMS\VpnDial\*.*"    Push "PhoneNumber=$destination_host"             #-- replace with anything within the " "
220      Push all                      #-- replace all occurrences
221    ; Remove directories used    Push all                      #-- replace all occurrences
222    RMDir /r "$SMPROGRAMS\VpnDial"    Push "$INSTDIR\pbk\connection.pbk"      #-- file to replace in
223    RMDir /r "$INSTDIR"    Call AdvReplaceInFile         #-- Call the Function
224    SectionEnd
225  SectionEnd  
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-$connectionname.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-$connectionname.lnk" "$INSTDIR\bin\VpnDial.exe" "--dial $connectionname" "$INSTDIR\bin\VpnDial.exe" 0
279      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

Legend:
Removed from v.1.3  
changed lines
  Added in v.1.12

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