--- joko/ToolBox/Windows/VpnDial-installer/vpn.nsi 2005/11/18 19:44:44 1.1 +++ joko/ToolBox/Windows/VpnDial-installer/vpn.nsi 2005/11/22 16:26:59 1.7 @@ -1,12 +1,15 @@ ; VpnDial.nsi -; $Id: vpn.nsi,v 1.1 2005/11/18 19:44:44 joko Exp $ +; $Id: vpn.nsi,v 1.7 2005/11/22 16:26:59 joko Exp $ ; ; This script can install VpnDial, ; has uninstall support and (optionally) installs start menu shortcuts. ; -!include "connection.nsi" -!include "vpn_functions.nsi" +!include "MUI.nsh" +!include "variables-declaration.nsi" +!include "string_functions.nsi" +!include "file_functions.nsi" +!include "ras_functions.nsi" ; -------------------------------- @@ -24,27 +27,128 @@ ; overwrite the old one automatically) InstallDirRegKey HKLM "Software\NSIS_VpnDial" "Install_Dir" -; more options: language of the installer & installer style -LoadLanguageFile "${NSISDIR}\Contrib\Language files\German.nlf" -XPStyle on +SetOverwrite on ; -------------------------------- -; Pages +; (MUI) Interface Settings ; -------------------------------- +!define MUI_ABORTWARNING +!define MUI_COMPONENTSPAGE_NODESC +!define MUI_ICON "key.ico" +!define MUI_UNICON "key.ico" + -Page components -Page directory -Page instfiles +; -------------------------------- +; Pages +; -------------------------------- UninstPage uninstConfirm UninstPage instfiles +!insertmacro MUI_PAGE_WELCOME +Page custom SetupPage1 +Page custom SetupPage2 +Page custom SetupPage3 +!insertmacro MUI_PAGE_COMPONENTS +!insertmacro MUI_PAGE_DIRECTORY +!insertmacro MUI_PAGE_INSTFILES + +!insertmacro MUI_UNPAGE_CONFIRM +!insertmacro MUI_UNPAGE_INSTFILES +!insertmacro MUI_LANGUAGE "German" + + +; -------------------------------- +; .onInit +; -------------------------------- + +Function .onInit + + System::Call 'kernel32::CreateMutexA(i 0, i 0, t "myMutex") i .r1 ?e' + Pop $R0 + StrCmp $R0 0 +3 + MessageBox MB_OK|MB_ICONEXCLAMATION "Die Installation läuft bereits." + Abort + + !insertmacro MUI_INSTALLOPTIONS_EXTRACT "vpndial_settings.ini" + !insertmacro MUI_INSTALLOPTIONS_EXTRACT "vpndial_settings_net.ini" + !insertmacro MUI_INSTALLOPTIONS_EXTRACT "vpndial_settings_cert.ini" +FunctionEnd + +Function SetupPage1 + ; custom page + ; see: http://nsis.sourceforge.net/Docs/Modern%20UI/Readme.html#customPages + ; and: http://nsis.sourceforge.net/Docs/InstallOptions/Readme.html + !insertmacro MUI_HEADER_TEXT "VpnDial Einstellungen" "Bitte füllen Sie folgende Angaben aus" + !insertmacro MUI_INSTALLOPTIONS_DISPLAY "vpndial_settings.ini" +FunctionEnd + +Function SetupPage2 + !insertmacro MUI_HEADER_TEXT "VpnDial Einstellungen" "Bitte füllen Sie folgende Angaben aus" + !insertmacro MUI_INSTALLOPTIONS_DISPLAY "vpndial_settings_net.ini" +FunctionEnd + +Function SetupPage3 + !insertmacro MUI_HEADER_TEXT "VpnDial Einstellungen" "Bitte füllen Sie folgende Angaben aus" + !insertmacro MUI_INSTALLOPTIONS_DISPLAY "vpndial_settings_cert.ini" +FunctionEnd + + ; -------------------------------- ; The stuff to install ; -------------------------------- Section + + ;Get Parameter from vpndial_settings.ini + + ;Get Connectionname + !insertmacro MUI_INSTALLOPTIONS_READ $connectionname "vpndial_settings.ini" "Field 2" "State" + ;MessageBox MB_OK $R1 + ;StrCpy $connectionname $R1 + + ;Get Destination_host + !insertmacro MUI_INSTALLOPTIONS_READ $destination_host "vpndial_settings.ini" "Field 3" "State" + ;MessageBox MB_OK $R2 + ;StrCpy $destination_host $R2 + + ;Get Username + !insertmacro MUI_INSTALLOPTIONS_READ $username "vpndial_settings.ini" "Field 4" "State" + + ;Get Password + !insertmacro MUI_INSTALLOPTIONS_READ $userpass "vpndial_settings.ini" "Field 8" "State" + + ;------------------------------------------------------------------------------------------------------------- + + ;Get Parameter from vpndial_settings_net.ini + + ;Get Destination_net + !insertmacro MUI_INSTALLOPTIONS_READ $R1 "vpndial_settings_net.ini" "Field 2" "State" + !insertmacro MUI_INSTALLOPTIONS_READ $R2 "vpndial_settings_net.ini" "Field 3" "State" + !insertmacro MUI_INSTALLOPTIONS_READ $R3 "vpndial_settings_net.ini" "Field 4" "State" + !insertmacro MUI_INSTALLOPTIONS_READ $R4 "vpndial_settings_net.ini" "Field 7" "State" + + StrCpy $destination_net "$R1.$R2.$R3.$R4" + + ;Get Destination_mask + !insertmacro MUI_INSTALLOPTIONS_READ $R5 "vpndial_settings_net.ini" "Field 12" "State" + !insertmacro MUI_INSTALLOPTIONS_READ $R6 "vpndial_settings_net.ini" "Field 13" "State" + !insertmacro MUI_INSTALLOPTIONS_READ $R7 "vpndial_settings_net.ini" "Field 14" "State" + !insertmacro MUI_INSTALLOPTIONS_READ $R8 "vpndial_settings_net.ini" "Field 15" "State" + + StrCpy $destination_mask "$R12.$R13.$R14.$R15" + + ;-------------------------------------------------------------------------------------------------------------- + + ;Get Parameter from vpndial_settings_cert.ini + + !insertmacro MUI_INSTALLOPTIONS_READ $cacert "vpndial_settings_cert.ini" "Field 2" "State" + !insertmacro MUI_INSTALLOPTIONS_READ $usercert "vpndial_settings_cert.ini" "Field 3" "State" + +SectionEnd + +Section SetShellVarContext all Push $APPDATA\Microsoft\Network\Connections\Pbk\rasphone.pbk Push "[$connectionname]" @@ -53,12 +157,14 @@ Pop $1 #Found at all? yes/no Pop $2 #Number of lines found in StrCmp $1 yes 0 +3 - MessageBox MB_OK "$\"[$connectionname]$\" was found already found. Cannot create. Sorry." + MessageBox MB_OK "Die Verbindung $\"$connectionname$\" existiert bereits. Der Eintrag kann leider nicht doppelt angelegt werden." Abort SectionEnd Section "VpnDial" IDX_VpnDial + SetOverwrite on + SetDetailsPrint both DetailPrint "Installiere VpnDial..." @@ -70,11 +176,8 @@ ;CreateDirectory $INSTDIR\certs\ ; Put file there - ;File /r "C:\IPSec\nsis\vpndial\*.*" File /r "vpndial\*.*" - ;File "C:\IPSec\nsis\vpndial\certs\" - ;File "C:\IPSec\nsis\vpndial\certs\*.*" - + ; Write the installation path into the registry WriteRegStr HKLM Software\NSIS_VpnDial "Install_Dir" "$INSTDIR" @@ -86,7 +189,13 @@ WriteUninstaller "uninstall.exe" SectionEnd - + + +; --------------------------------------------------------------------------- +; pbk-Datei anpassen +; --------------------------------------------------------------------------- + +; Verbindungsname Section DetailPrint "Installiere VPN-Verbindung..." Push "[##connectionname##]" #-- text to be replaced within the " " @@ -97,6 +206,7 @@ Call AdvReplaceInFile #-- Call the Function SectionEnd +; Gegenstelle Section Push "PhoneNumber=##destinationhost##" #-- text to be replaced within the " " Push "PhoneNumber=$destination_host" #-- replace with anything within the " " @@ -105,7 +215,20 @@ Push "$INSTDIR\pbk\connection.pbk" #-- file to replace in Call AdvReplaceInFile #-- Call the Function SectionEnd - + +; GUID +Section + Call CreateRasGUID + Pop $0 ; contains GUID + Push "Guid=##guid##" #-- text to be replaced within the " " + Push "Guid=$0" #-- replace with anything within the " " + Push all #-- replace all occurrences + Push all #-- replace all occurrences + Push "$INSTDIR\pbk\connection.pbk" #-- file to replace in + Call AdvReplaceInFile #-- Call the Function +SectionEnd + +; Verbindungsdatei mit globaler Datei zusammenführen Section SetShellVarContext all Push $INSTDIR\pbk\rasphone.pbk @@ -122,15 +245,17 @@ SectionEnd Section -nsExec::Exec "$INSTDIR\bin\certmgr.exe -add -c $INSTDIR\certs\$cacert -s -r localMachine root" +;nsExec::Exec "$INSTDIR\bin\certmgr.exe -add -c $INSTDIR\certs\$cacert -s -r localMachine root" +;nsExec::Exec "$INSTDIR\bin\certmgr.exe -add -c $cacert -s -r localMachine root" SectionEnd Section -nsExec::Exec "$INSTDIR\bin\winhttpcertcfg.exe -g -i $INSTDIR\certs\$usercert -c LOCAL_MACHINE\My -a $currentuser" +;nsExec::Exec "$INSTDIR\bin\winhttpcertcfg.exe -g -i $INSTDIR\certs\$usercert -c LOCAL_MACHINE\My -a $currentuser" +nsExec::Exec "$INSTDIR\bin\winhttpcertcfg.exe -g -i $usercert -c LOCAL_MACHINE\My -a $currentuser" SectionEnd ; Optional section (can be disabled by the user) -Section "Start Menu Shortcuts" IDX_STARTMENU +Section "Startmenü-Einträge" IDX_STARTMENU SetDetailsPrint both DetailPrint "Installiere Startmenü-Einträge und Desktop-Verknüpfungen..." @@ -142,15 +267,14 @@ ;CreateShortCut "$SMPROGRAMS\VpnDial\VpnSetup.lnk" "$INSTDIR\bin\VpnDial.exe" "--setup $connectionname --user $username --pass $userpass" "$INSTDIR\bin\VpnDial.exe" 0 CreateShortCut "$SMPROGRAMS\VpnDial\Zertifikate.lnk" "$INSTDIR\certs\" "" "$INSTDIR\certs\" 0 CreateShortCut "$SMPROGRAMS\VpnDial\ZertifikatsVerwaltung.lnk" "$INSTDIR\links\IPSec.msc" "" "$INSTDIR\links\IPSec.msc" 0 - CreateShortCut "$SMPROGRAMS\VpnDial\README.lnk" "$INSTDIR\doc\README.txt" "" "$INSTDIR\doc\README.txt" 0 - CreateShortCut "$SMPROGRAMS\VpnDial\README-HTML.lnk" "$INSTDIR\doc\README.htm" "" "$INSTDIR\doc\README.htm" 0 + ;CreateShortCut "$SMPROGRAMS\VpnDial\README.lnk" "$INSTDIR\doc\README.txt" "" "$INSTDIR\doc\README.txt" 0 + ;CreateShortCut "$SMPROGRAMS\VpnDial\README-HTML.lnk" "$INSTDIR\doc\README.htm" "" "$INSTDIR\doc\README.htm" 0 CopyFiles "$INSTDIR\links\Netzwerkverbindung*" "$SMPROGRAMS\VpnDial\" SectionEnd - ; -------------------------------- ; Uninstaller ; --------------------------------