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

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

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