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

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

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