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

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