!include "MUI.nsh" !define MUI_ABORTWARNING ;"Do you really want to quit the installer?" ################################################################ # Einbinden externer Scripte # ################################################################ !include "Registry.nsh" ;externs Registry script einbinden # !include "LogicLib.nsh" ;Logische Bibliothek für if,etc. # !include "DotNET.nsh" ;externs DotNet script einbinden # #!include "CheckODBC.nsi" ;externes CheckODBC Script einbinden # !include "x64.nsh" # ################################################################ !define PRODUCT_NAME "Custom ODBC-Connection" ;steht im Header des Installers !define PRODUCT_VERSION "0.1" !define PRODUCT_PUBLISHER "Pickert & Partner GmbH" !define PRODUCT_WEB_SITE "http://www.pickert.de" !define Version "RQM" ;Versionsname !define SetupFile "${PRODUCT_NAME}Setup" #OutFile schreiben Name "${PRODUCT_NAME}" ;PRODUCT_NAME "Custom ODBC-Connection" OutFile "Installer/${SETUPFILE}.exe" ;SetupFile "${PRODUCT_NAME}Setup" | PRODUCT_NAME "Custom ODBC-Connection" BrandingText "Pickert und Partner GmbH" #Pages definitionen Page custom getServerInfo Page custom checkServerInfo ################################################################ # Einbinden von Makros # ################################################################ !insertmacro MUI_PAGE_COMPONENTS ;not needed for 1 component # !insertmacro MUI_PAGE_INSTFILES # !insertmacro MUI_LANGUAGE "English" # ################################################################ LangString PAGE_NAMECOMPANY_TITLE ${LANG_ENGLISH} "Pickert und Partner" LangString PAGE_NAMECOMPANY_SUBTITLE ${LANG_ENGLISH} "This setup will install the neccessary ODBC-Entry$\nto use the RQM database." #Variablen Definitionen Var Server Var Database Var Description #Abfrage ob Installer ausgeführt werden soll, wenn ja PluginsDir Initialisierung Function ".onInit" ;Wird bei der Initialisierung ausgeführt MessageBox MB_YESNO "This will install the ODBC connection to RQM. Do you wish to continue?" IDYES gogo Abort gogo: InitPluginsDir File /oname=$PLUGINSDIR\Layout.ini "Layout.ini" FunctionEnd ; Ende Funktion .onInit Function getServerInfo !insertmacro MUI_HEADER_TEXT $(PAGE_NAMECOMPANY_TITLE) $(PAGE_NAMECOMPANY_SUBTITLE) Push $R1 MessageBox MB_OK "$R1" InstallOptions::dialog $PLUGINSDIR\Layout.ini Pop $R1 ReadINIStr $Server "$PLUGINSDIR\Layout.ini" "Field 5" "state" ReadINIStr $Database "$PLUGINSDIR\Layout.ini" "Field 7" "state" ReadINIStr $Description "$PLUGINSDIR\Layout.ini" "Field 9" "state" Pop $R1 FunctionEnd ; Ende Funktion getServerInfo Function checkServerInfo !insertmacro MUI_HEADER_TEXT $(PAGE_NAMECOMPANY_TITLE) $(PAGE_NAMECOMPANY_SUBTITLE) FunctionEnd #Installroutine Section InstallODBC ${Ifnot} $Server == "" ${Ifnot} $Database == "" ${If} ${RunningX64} call Install64bit ${Else} call Install32bit ${EndIf} ;ruft die Function Install auf ${Else} MessageBox MB_OK "Please check if you have entered Server and Database!" Abort ${Endif} ${Else} MessageBox MB_OK "Please check if you have entered Server and Database!" Abort ${Endif} SectionEnd ; Ende Section InstallODBC ;ODBC einträge erstellen Function Install32bit #!insertmacro ODBCEntryExistsMacro ;fügt das macro ODBCEntryExistsMacro dazu, welches sich in der Externen Datei CheckODBC.nsi befindet ;Odbc eintrag ReadRegStr $R0 HKLM "SYSTEM\CurrentControlSet\Control\ComputerName\ComputerName" "ComputerName" ;liest den Computer Namen aus und schreibt ihn in eine Variable WriteRegStr HKEY_LOCAL_MACHINE "SOFTWARE\ODBC\ODBC.INI\ODBC Data Sources" "$Database" "SQL Server" WriteRegStr HKEY_LOCAL_MACHINE "SOFTWARE\ODBC\ODBC.INI\$Database" "Database" "$Database" WriteRegStr HKEY_LOCAL_MACHINE "SOFTWARE\ODBC\ODBC.INI\$Database" "Driver" "$SYSDIR\SQLSRV32.dll" WriteRegStr HKEY_LOCAL_MACHINE "SOFTWARE\ODBC\ODBC.INI\$Database" "Description" "$Database" WriteRegStr HKEY_LOCAL_MACHINE "SOFTWARE\ODBC\ODBC.INI\$Database" "Server" "$R0\$Database" WriteRegStr HKEY_LOCAL_MACHINE "SOFTWARE\ODBC\ODBC.INI\$Database" "LastUser" "rqmdb" MessageBox MB_YESNO "Do you want to open the ODBC Connection Manager?" IDNO noManager ExecShell "" "C:\Windows\system32\odbcad32.exe" noManager: FunctionEnd ; Ende Function Install32bit Function Install64bit #!insertmacro ODBCEntryExistsMacro ;fügt das macro ODBCEntryExistsMacro dazu, welches sich in der Externen Datei CheckODBC.nsi befindet ;Odbc eintrag ReadRegStr $R0 HKLM "SYSTEM\CurrentControlSet\Control\ComputerName\ComputerName" "ComputerName" ;liest den Computer Namen aus und schreibt ihn in eine Variable WriteRegStr HKEY_LOCAL_MACHINE "SOFTWARE\Wow6432Node\ODBC\ODBC.INI\ODBC Data Sources" "$Database" "SQL Server" WriteRegStr HKEY_LOCAL_MACHINE "SOFTWARE\Wow6432Node\ODBC\ODBC.INI\$Database" "Database" "$Database" WriteRegStr HKEY_LOCAL_MACHINE "SOFTWARE\Wow6432Node\ODBC\ODBC.INI\$Database" "Driver" "$SYSDIR\SQLSRV32.dll" WriteRegStr HKEY_LOCAL_MACHINE "SOFTWARE\Wow6432Node\ODBC\ODBC.INI\$Database" "Description" "$Database" WriteRegStr HKEY_LOCAL_MACHINE "SOFTWARE\Wow6432Node\ODBC\ODBC.INI\$Database" "Server" "$R0\$Database" WriteRegStr HKEY_LOCAL_MACHINE "SOFTWARE\Wow6432Node\ODBC\ODBC.INI\$Database" "LastUser" "rqmdb" MessageBox MB_YESNO "Do you want to open the ODBC Connection Manager?" IDNO noManager ExecShell "" "C:\Windows\sysWow64\odbcad32.exe" noManager: FunctionEnd ; Ende Function Install64bit