neo-layout/windows/Neo2.0_installer.nsi

354 lines
15 KiB
Plaintext
Raw Permalink Normal View History

;NSIS-Installer f<>r alle Windowstreiber
;Geschrieben von Florian Jan<61>en
;
; Offene Punkte:
; - Uninstaller
2010-02-10 23:51:38 +01:00
; - bislang keine Abfrage ob Autostart
;
; Status:
2010-02-10 23:51:38 +01:00
; - Installiert kbdneo (mit und ohne Zustatzskript)
; - F<>llt bei Bedarf auf NeoVars-Installation zur<75>ck
; - Erkennt 32- und 64bit Systeme und w<>hlt entsprechenden Treiber aus.
; - Kann auf die 64bit Registry und 64bit-Systemordner von Vista und 7 zugreifen
2010-02-10 23:51:38 +01:00
; - Rechteverwaltung bei XP, Vista und 7
; - Autostart wird angelegt
;--------------------------------
;MUI Oberfl<66>che
;Nur eine Section ausw<73>hlbar
;64bit Zauberei
2010-02-10 23:51:38 +01:00
;bisschen Logik
;Benutzerkontensteuerung
!include "MUI2.nsh"
!include "Sections.nsh"
!include "x64.nsh"
!include "LogicLib.nsh"
!include "UAC.nsh"
!include "WinVer.nsh"
2010-02-10 23:51:38 +01:00
;--------------------------------
;Allgemeines
;Name und Name der Datei
2010-02-10 23:51:38 +01:00
!define /date ZEIT "%y%m%d.%H"
2011-05-18 22:40:34 +02:00
Name "Neo 2.0 - Das ergonomische Tastaturlayout"
2010-02-10 23:51:38 +01:00
OutFile "Neo2.0_setup.exe"
;Standardordner (f<>r AHK)
2010-02-10 23:51:38 +01:00
InstallDir "$PROGRAMFILES\Neo2"
;Mal sehen ob Neo schon mal da war
2010-02-10 23:51:38 +01:00
InstallDirRegKey HKCU "Software\Neo 2.0" ""
;Rechte anfordern
2010-02-10 23:51:38 +01:00
RequestExecutionLevel user ;Muss <20>user<65> sein, Admin wird nachtr<74>glich gerufen
2010-02-10 23:51:38 +01:00
;Zeige was geschieht
ShowInstDetails show
;Warnung bei Abbruch
2010-02-10 23:51:38 +01:00
!define MUI_ABORTWARNING ;Warnt falls Installations abgebrochen wird
Var pre_sel
Var DlgItem
;--------------------------------
;Seiten des Installers
2010-02-10 23:51:38 +01:00
!define WELCOME_TITLE "Willkommen zum Installations- Assistenten f<>r Neo 2.0"
!define UNWELCOME_TITLE "Willkommen zum Deinstallations- Assistenten f<>r Neo 2.0"
!define FINISH_TITLE "Die Installation von Neo 2.0 wurde erfolgreich beendet."
!define UNFINISH_TITLE "Die Deinstallation von Neo 2.0 wurde erfolgreich beendet."
!define MUI_COMPONENTSPAGE_SMALLDESC
!define MUI_ICON "kbdneo2\Treiber\AHK_f<5F>r_kbdneo2\neo_enabled.ico"
!define MUI_HEADERIMAGE
!define MUI_HEADERIMAGE_RIGHT
!define MUI_HEADERIMAGE_BITMAP logo.bmp
2010-02-10 23:51:38 +01:00
!define MUI_WELCOMEPAGE_TITLE "${WELCOME_TITLE}"
!define MUI_WELCOMEPAGE_TITLE_3LINES ;3 Zeilen f<>r den Titel
!define MUI_PAGE_CUSTOMFUNCTION_PRE preAdmin1
2010-02-10 23:51:38 +01:00
!insertmacro MUI_PAGE_WELCOME
;!insertmacro MUI_PAGE_LICENSE "lizenz.txt"
2010-02-10 23:51:38 +01:00
!define MUI_PAGE_CUSTOMFUNCTION_PRE preComp
!define MUI_PAGE_CUSTOMFUNCTION_LEAVE leaveComp
!insertmacro MUI_PAGE_COMPONENTS
!define MUI_PAGE_CUSTOMFUNCTION_PRE preDir
!insertmacro MUI_PAGE_DIRECTORY
!define MUI_PAGE_CUSTOMFUNCTION_LEAVE leaveInst
!insertmacro MUI_PAGE_INSTFILES
!define MUI_FINISHPAGE_TITLE "${FINISH_TITLE}"
!define MUI_FINISHPAGE_TITLE_3LINES
;!define MUI_FINISHPAGE_RUN "$INSTDIR\neo20.exe"
2010-02-10 23:51:38 +01:00
!insertmacro MUI_PAGE_FINISH
2010-02-10 23:51:38 +01:00
;Deutsche Oberfl<66>che
!insertmacro MUI_LANGUAGE "German"
2010-02-10 23:51:38 +01:00
;---------------------------------
;Ein paar Variablen
!define KLF_REORDER 8
!define KLF_ACTIVATE 1
;--------------------------------
;Installer Sections
;Verschiedene Installationstypen
InstType "Vollst<73>ndig"
InstType "Nur Teiber kein Skript"
InstType "Nur NeoVars"
;InstType /NOCUSTOM
2010-02-10 23:51:38 +01:00
;Die eigentlichen Sections
Section /o "Neo-2.0-Treiber" installiereKbdneoOhneAHK
SectionIn 2
SetOutPath "$SYSDIR"
${If} ${RunningX64}
SetRegView 64
WriteRegStr HKEY_LOCAL_MACHINE "SYSTEM\CurrentControlSet\Control\Keyboard Layouts\b0000407" "Layout Text" "Deutsch (Neo 2.0 ergonomisch)"
WriteRegStr HKEY_LOCAL_MACHINE "SYSTEM\CurrentControlSet\Control\Keyboard Layouts\b0000407" "Layout File" "kbdneo2.dll"
WriteRegStr HKEY_LOCAL_MACHINE "SYSTEM\CurrentControlSet\Control\Keyboard Layouts\b0000407" "Layout Id" "00c0"
WriteRegStr HKEY_LOCAL_MACHINE "SYSTEM\CurrentControlSet\Control\Keyboard Layouts\b0000407" "Layout Display Name" "@%SystemRoot%\system32\kbdneo2.dll,-1000"
WriteRegStr HKEY_LOCAL_MACHINE "SYSTEM\CurrentControlSet\Control\Keyboard Layouts\b0000407" "Custom Language Name" "German (Germany)"
WriteRegStr HKEY_LOCAL_MACHINE "SYSTEM\CurrentControlSet\Control\Keyboard Layouts\b0000407" "Custom Language Display Name" "@%SystemRoot%\system32\kbdneo2.dll,-1100"
SetRegView 32
2011-05-18 22:40:34 +02:00
WriteRegStr HKEY_LOCAL_MACHINE "SYSTEM\CurrentControlSet\Control\Keyboard Layouts\b0000407" "Layout Text" "Deutsch (Neo 2.0 ergonomisch)"
WriteRegStr HKEY_LOCAL_MACHINE "SYSTEM\CurrentControlSet\Control\Keyboard Layouts\b0000407" "Layout File" "kbdneo2.dll"
WriteRegStr HKEY_LOCAL_MACHINE "SYSTEM\CurrentControlSet\Control\Keyboard Layouts\b0000407" "Layout Id" "00c0"
WriteRegStr HKEY_LOCAL_MACHINE "SYSTEM\CurrentControlSet\Control\Keyboard Layouts\b0000407" "Layout Display Name" "@%SystemRoot%\system32\kbdneo2.dll,-1000"
WriteRegStr HKEY_LOCAL_MACHINE "SYSTEM\CurrentControlSet\Control\Keyboard Layouts\b0000407" "Custom Language Name" "German (Germany)"
WriteRegStr HKEY_LOCAL_MACHINE "SYSTEM\CurrentControlSet\Control\Keyboard Layouts\b0000407" "Custom Language Display Name" "@%SystemRoot%\system32\kbdneo2.dll,-1100"
2010-02-10 23:51:38 +01:00
${DisableX64FSRedirection}
2011-05-18 22:40:34 +02:00
file kbdneo2\Treiber\64bit_Windows\System32\kbdneo2.dll
${EnableX64FSRedirection}
file kbdneo2\Treiber\64bit_Windows\SysWOW64\kbdneo2.dll
${Else}
2010-02-10 23:51:38 +01:00
SetRegView 32
WriteRegStr HKEY_LOCAL_MACHINE "SYSTEM\CurrentControlSet\Control\Keyboard Layouts\b0000407" "Layout Text" "Deutsch (Neo 2.0 ergonomisch)"
WriteRegStr HKEY_LOCAL_MACHINE "SYSTEM\CurrentControlSet\Control\Keyboard Layouts\b0000407" "Layout File" "kbdneo2.dll"
WriteRegStr HKEY_LOCAL_MACHINE "SYSTEM\CurrentControlSet\Control\Keyboard Layouts\b0000407" "Layout Id" "00c0"
WriteRegStr HKEY_LOCAL_MACHINE "SYSTEM\CurrentControlSet\Control\Keyboard Layouts\b0000407" "Layout Display Name" "@%SystemRoot%\system32\kbdneo2.dll,-1000"
WriteRegStr HKEY_LOCAL_MACHINE "SYSTEM\CurrentControlSet\Control\Keyboard Layouts\b0000407" "Custom Language Name" "German (Germany)"
WriteRegStr HKEY_LOCAL_MACHINE "SYSTEM\CurrentControlSet\Control\Keyboard Layouts\b0000407" "Custom Language Display Name" "@%SystemRoot%\system32\kbdneo2.dll,-1100"
${EnableX64FSRedirection}
file kbdneo2\Treiber\32bit_Windows\kbdneo2.dll
${EndIf}
;!insertmacro UAC_AsUser_Call Function makeKBDactive ${UAC_SYNCREGISTERS}
2010-02-10 23:51:38 +01:00
SectionEnd
2010-02-10 23:51:38 +01:00
Section /o "Neo-2.0-Treiber und AHK-Erweiterung" installiereKbdneoPlusAHK
SectionIn 1
SetOutPath "$INSTDIR"
;Zustatz Skript kopieren (immer als 32bit)
2010-02-10 23:51:38 +01:00
file kbdneo2\Treiber\AHK_f<5F>r_kbdneo2\kbdneo_ahk.exe
;Erstellt eine Verkn<6B>pfung im Autostart-Ordner
2010-02-10 23:51:38 +01:00
!insertmacro UAC_AsUser_Call Function goUserDir ${UAC_SYNCREGISTERS}
SetOutPath "$SYSDIR"
${If} ${RunningX64}
2011-05-18 22:40:34 +02:00
SetRegView 64
2010-02-10 23:51:38 +01:00
WriteRegStr HKEY_LOCAL_MACHINE "SYSTEM\CurrentControlSet\Control\Keyboard Layouts\b0000407" "Layout Text" "Deutsch (Neo 2.0 ergonomisch)"
WriteRegStr HKEY_LOCAL_MACHINE "SYSTEM\CurrentControlSet\Control\Keyboard Layouts\b0000407" "Layout File" "kbdneo2.dll"
WriteRegStr HKEY_LOCAL_MACHINE "SYSTEM\CurrentControlSet\Control\Keyboard Layouts\b0000407" "Layout Id" "00c0"
WriteRegStr HKEY_LOCAL_MACHINE "SYSTEM\CurrentControlSet\Control\Keyboard Layouts\b0000407" "Layout Display Name" "@%SystemRoot%\system32\kbdneo2.dll,-1000"
WriteRegStr HKEY_LOCAL_MACHINE "SYSTEM\CurrentControlSet\Control\Keyboard Layouts\b0000407" "Custom Language Name" "German (Germany)"
WriteRegStr HKEY_LOCAL_MACHINE "SYSTEM\CurrentControlSet\Control\Keyboard Layouts\b0000407" "Custom Language Display Name" "@%SystemRoot%\system32\kbdneo2.dll,-1100"
SetRegView 32
2011-05-18 22:40:34 +02:00
WriteRegStr HKEY_LOCAL_MACHINE "SYSTEM\CurrentControlSet\Control\Keyboard Layouts\b0000407" "Layout Text" "Deutsch (Neo 2.0 ergonomisch)"
WriteRegStr HKEY_LOCAL_MACHINE "SYSTEM\CurrentControlSet\Control\Keyboard Layouts\b0000407" "Layout File" "kbdneo2.dll"
WriteRegStr HKEY_LOCAL_MACHINE "SYSTEM\CurrentControlSet\Control\Keyboard Layouts\b0000407" "Layout Id" "00c0"
WriteRegStr HKEY_LOCAL_MACHINE "SYSTEM\CurrentControlSet\Control\Keyboard Layouts\b0000407" "Layout Display Name" "@%SystemRoot%\system32\kbdneo2.dll,-1000"
WriteRegStr HKEY_LOCAL_MACHINE "SYSTEM\CurrentControlSet\Control\Keyboard Layouts\b0000407" "Custom Language Name" "German (Germany)"
WriteRegStr HKEY_LOCAL_MACHINE "SYSTEM\CurrentControlSet\Control\Keyboard Layouts\b0000407" "Custom Language Display Name" "@%SystemRoot%\system32\kbdneo2.dll,-1100"
2010-02-10 23:51:38 +01:00
${DisableX64FSRedirection}
2011-05-18 22:40:34 +02:00
file kbdneo2\Treiber\64bit_Windows\System32\kbdneo2.dll
${EnableX64FSRedirection}
file kbdneo2\Treiber\64bit_Windows\SysWOW64\kbdneo2.dll
2010-02-10 23:51:38 +01:00
${Else}
SetRegView 32
WriteRegStr HKEY_LOCAL_MACHINE "SYSTEM\CurrentControlSet\Control\Keyboard Layouts\b0000407" "Layout Text" "Deutsch (Neo 2.0 ergonomisch)"
WriteRegStr HKEY_LOCAL_MACHINE "SYSTEM\CurrentControlSet\Control\Keyboard Layouts\b0000407" "Layout File" "kbdneo2.dll"
WriteRegStr HKEY_LOCAL_MACHINE "SYSTEM\CurrentControlSet\Control\Keyboard Layouts\b0000407" "Layout Id" "00c0"
WriteRegStr HKEY_LOCAL_MACHINE "SYSTEM\CurrentControlSet\Control\Keyboard Layouts\b0000407" "Layout Display Name" "@%SystemRoot%\system32\kbdneo2.dll,-1000"
WriteRegStr HKEY_LOCAL_MACHINE "SYSTEM\CurrentControlSet\Control\Keyboard Layouts\b0000407" "Custom Language Name" "German (Germany)"
WriteRegStr HKEY_LOCAL_MACHINE "SYSTEM\CurrentControlSet\Control\Keyboard Layouts\b0000407" "Custom Language Display Name" "@%SystemRoot%\system32\kbdneo2.dll,-1100"
${EnableX64FSRedirection}
file kbdneo2\Treiber\32bit_Windows\kbdneo2.dll
2010-02-10 23:51:38 +01:00
${EndIf}
;!insertmacro UAC_AsUser_Call Function makeKBDactive ${UAC_SYNCREGISTERS}
2010-02-10 23:51:38 +01:00
SectionEnd
2010-02-10 23:51:38 +01:00
Section /o "Eigenst<73>ndiges Neo2.0-AHK-Skript (NeoVars)" installiereAHK
SectionIn 3
SetOutPath "$INSTDIR"
file neo-vars\out\neo20.exe
createShortCut "$SMPROGRAMS\Startup\Neo2.0 (AHK).lnk" "$INSTDIR\neo20.exe"
WriteRegStr HKCU "Software\Neo 2.0" "" $INSTDIR
SectionEnd
2010-02-10 23:51:38 +01:00
;--------------------------------
; Functions
Function .onInit
StrCpy $pre_sel ${installiereKbdneoPlusAHK}
FunctionEnd
2010-02-10 23:51:38 +01:00
;nur ein Installationszweig ausw<73>hlbar
Function .onSelChange
!insertmacro StartRadioButtons $pre_sel
2010-02-10 23:51:38 +01:00
!insertmacro RadioButton ${installiereKbdneoOhneAHK}
!insertmacro RadioButton ${installiereKbdneoPlusAHK}
!insertmacro RadioButton ${installiereAHK}
!insertmacro EndRadioButtons
FunctionEnd
;Durch Erwerb der Adminrechte neu gestartet, dann Willkommens_Seite <20>berspringen
Function preAdmin1
${IfNot} ${AtLeastWinVista}
goto noSkip
${EndIf}
userInfo::getAccountType
pop $R0
strCmp $R0 "Admin" +2
goto noSkip
StrCpy $pre_sel ${installiereKbdneoPlusAHK}
Abort
noSkip:
FunctionEnd
2010-02-10 23:51:38 +01:00
;UAC Zauberei
Function preComp
2010-02-10 23:51:38 +01:00
uac_tryagain:
!insertmacro UAC_RunElevated
;MessageBox mb_TopMost "0=$0 1=$1 2=$2 3=$3"
2010-02-10 23:51:38 +01:00
${Switch} $0
${Case} 0
${IfThen} $1 = 1 ${|} Quit ${|} ;we are the outer process, the inner process has done its work, we are done
${IfThen} $3 <> 0 ${|} ${Break} ${|} ;we are admin, let the show go on
${If} $1 = 3 ;RunAs completed successfully, but with a non-admin user
MessageBox mb_IconExclamation|mb_TopMost|mb_SetForeground "Dieser Installationsassistent ben<65>tigt Adminrechte, bitte erneut versuchen." /SD IDNO IDOK uac_tryagain IDNO 0
${EndIf}
;fall-through and die
2010-02-10 23:51:38 +01:00
${Case} 1223 ;hier kommt der Ausstieg falls der User keine Adminrechte erwerben kann.
;MessageBox MB_YESNO|mb_IconStop|mb_TopMost|mb_SetForeground "F<>r die Installation des Windowstreibers werden Adminrechte ben<65>tigt. Mit NeoVars kann jedoch auch ohne Adminrechte das Neo2.0-Tastaturlayout installiert werden. Bitte die Hinweise auf der Website beachten. Soll Neo-Vars gestartet werden?" IDYES gogogo
;ExecShell "open" "http://neo-layout.org/windows"
;Quit
;gogogo:
2010-02-10 23:51:38 +01:00
ExecShell "open" http://neo-layout.org/windows
goto end
${Case} 1062
MessageBox mb_IconStop|mb_TopMost|mb_SetForeground "Logon-Dienst nicht verf<72>gbar, Abbruch!"
Quit
${Default}
MessageBox mb_IconStop|mb_TopMost|mb_SetForeground "Ups , Error $0"
Quit
${EndSwitch}
end:
;Sperrt ohne Adminrechte alles au<61>er NeoVars
GetDlgItem $DlgItem $HWNDPARENT 3 ; Back button
EnableWindow $DlgItem 0
2010-02-10 23:51:38 +01:00
userInfo::getAccountType
pop $R0
strCmp $R0 "Admin" +6 ;falls Admin h<>pf 6 Commandozeilen weiter
;wenn kein Admin wird das hier angezeigt:
messageBox MB_OK "Nur $R0-Rechte. Ohne Adminrechte ist nur der NeoVars-Treiber verf<72>gbar."
SectionSetFlags ${installiereKbdneoPlusAHK} ${SF_RO} ;Installationsarten mit Adminrechten werden gesperrt
SectionSetFlags ${installiereKbdneoOhneAHK} ${SF_RO} ;Installationsarten mit Adminrechten werden gesperrt
SectionSetFlags ${installiereAHK} ${SF_SELECTED}
return
;messageBox MB_OK "Wir sind Admin"
2010-02-10 23:51:38 +01:00
FunctionEnd
2010-02-10 23:51:38 +01:00
;<3B>berspringt die Directory-Seite falls kein AHK installiert wird
Function leaveComp
SectionGetFlags ${installiereKbdneoOhneAHK} $0
IntOp $1 $0 & ${SF_SELECTED}
IntCmp $1 0 showDir
push "skip components" ;schiebt es auf den Stack
showDir:
FunctionEnd
2010-02-10 23:51:38 +01:00
Function preDir
pop $R0 ;holt es sich vom Stack zur<75>ck
StrCmp "$R0" "skip components" 0 end ;vergleicht es und springt zu Ende wenn es nicht passt
abort ;hat gepasst, Components-Seite wird <20>bersprungen.
end:
FunctionEnd
2010-02-10 23:51:38 +01:00
;Verschafft etwas Zeit zum Kucken
Function leaveInst
sleep 1500 ;Ein bisschen Pause, damit man was sieht.
2010-02-10 23:51:38 +01:00
FunctionEnd
;Layout beim User Aktivieren (hoffentlich ;)
;Function makeKBDactive
; System::Call "user32::LoadKeyboardLayout(t "b0000407",i 0x00000001) i .r1 ?e"
; Pop $2
; MessageBox mb_TopMost "0:$0 1:$1 2:$2 3:$3"
;FunctionEnd
2010-02-10 23:51:38 +01:00
;Datei beim User schreiben, obwohl als Admin eingeloggt
Function goUserDir
createShortCut "$SMPROGRAMS\Startup\AHK f<>r kbdneo.lnk" "$INSTDIR\kbdneo_ahk.exe"
FunctionEnd
;--------------------------------
2010-02-10 23:51:38 +01:00
;Beschreibung der Installationstypen
;LangsStrings (nur Deutsch)
LangString DESC_installiereKbdneoPlusAHK ${LANG_GERMAN} "System32-Test und bel. Ordner (hier sollten immer Adminrechte angefordert werden)"
LangString DESC_installiereKbdneoOhneAHK ${LANG_GERMAN} "nur System32-Test (hier sollten immer Adminrechte angefordert werden)"
LangString DESC_installiereAHK ${LANG_GERMAN} "Installiert den Neo2.0-AHK-Standalone-Treiber Neo-Vars (keine Adminrechte n<>tig)"
2010-02-10 23:51:38 +01:00
;LangsStrings den Sections zuordnen
!insertmacro MUI_FUNCTION_DESCRIPTION_BEGIN
!insertmacro MUI_DESCRIPTION_TEXT ${installiereKbdneoPlusAHK} $(DESC_installiereKbdneoPlusAHK)
!insertmacro MUI_DESCRIPTION_TEXT ${installiereKbdneoOhneAHK} $(DESC_installiereKbdneoOhneAHK)
!insertmacro MUI_DESCRIPTION_TEXT ${installiereAHK} $(DESC_installiereAHK)
!insertmacro MUI_FUNCTION_DESCRIPTION_END
2010-02-10 23:51:38 +01:00
;---------------------------------
;Dateieigenschaften des Installers
VIAddVersionKey /LANG=${LANG_GERMAN} "ProductName" "Neo 2.0"
VIAddVersionKey /LANG=${LANG_GERMAN} "Comments" "Buy me a Caff<66> /;)"
VIAddVersionKey /LANG=${LANG_GERMAN} "FileDescription" "Neo 2.0 Installationsassistent"
VIAddVersionKey /LANG=${LANG_GERMAN} "FileVersion" "${ZEIT}"
VIProductVersion "2.0.${ZEIT}"