# MGIS_VAlpha3_1.nsi ;-------------------------------- ;-------------------------------- #Include Modern UI !include "MUI.nsh" !include "Sections.nsh" !include "zipdll.nsh" !include "WriteINILargeStr.nsh" !include "AddToPath.nsh" !include "WordFunc.nsh" !include "TextFunc.nsh" ;-------------------------------- ;Version ;-------------------------------- ;defining the version number !define VERSION "Beta 3.0" ;defining the application name !define APPLICATION_NAME "MGIS" ;defining the full application name !define APPLICATION_FULLNAME "Musa Germplasm Information System" ;defining the window class of the app !define WNDCLASS "WindowClassOfYourApplication" ;defining the title omy application !define WNDTITLE "MGIS" !macro IndexOf Var Str Char Push "${Char}" Push "${Str}" Call IndexOf Pop "${Var}" !macroend !define IndexOf "!insertmacro IndexOf" ;-------------------------------- ;Tools ;-------------------------------- ;-------------------------------- ;General ;-------------------------------- ;Name and file # The name to be displayed on the installer Name "${APPLICATION_NAME} - ${VERSION}" # The file to write and will be launched by the user OutFile "SETUP_MGIS_VBeta3_0.exe" ;Default installation folder InstallDir "$PROGRAMFILES\MGISV3A" ;Get installation folder from registry if available InstallDirRegKey HKCU "Software\MGIS 3" "" ;-------------------------------- ;Variables Var MUI_TEMP Var STARTMENU_FOLDER Var JAVA_VER Var MGIS_VER Var CDROM_LETTER Var LOCAL_INSTALL Var SERVER_INSTALL Var DESKTOP_INSTALL VAR DB_SERVER_NAME VAR DB_PORT_NUMBER VAR DB_LOGIN VAR DB_PWD VAR NET_PATH VAR JAVA_HOME VAR JAVA_INSTALLATION_MSG ;-------------------------------- ;Interface Settings !define MUI_ABORTWARNING !define MUI_ICON "banana.ico" !define MUI_UNICON "banana.ico" !define MUI_HEADERIMAGE !define MUI_HEADERIMAGE_BITMAP "178.bmp" !define MUI_WELCOMEFINISHPAGE_BITMAP "44bio.bmp" !define MUI_FINISHPAGE_NOAUTOCLOSE !define MUI_UNFINISHPAGE_NOAUTOCLOSE !define MUI_CUSTOMFUNCTION_DIRECTORY_PRE DirectoryPre !define MUI_CUSTOMFUNCTION_DIRECTORY_SHOW DirectoryShow !define MUI_CUSTOMFUNCTION_DIRECTORY_LEAVE DirectoryLeave ;-------------------------------- ;Language Selection Dialog Settings ;Remember the installer language !define MUI_LANGDLL_REGISTRY_ROOT "HKCU" !define MUI_LANGDLL_REGISTRY_KEY "Software\MGIS 3" !define MUI_LANGDLL_REGISTRY_VALUENAME "Installer Language" ;-------------------------------- ; Custom Page for Instalation mode i.e. Local or Server or Desktop Function SelInstMode_show !insertmacro MUI_HEADER_TEXT "$(TEXT_SELINSTMODE_TITLE)" "$(TEXT_SELINSTMODE_SUBTITLE)" !insertmacro MUI_INSTALLOPTIONS_DISPLAY "SelInst3Mode.ini" FunctionEnd ;-------------------------------- ; Function called when leaving the custom page SelInstMode Function SelInstMode_leave !insertmacro MUI_INSTALLOPTIONS_READ $LOCAL_INSTALL "SelInst3Mode.ini" "Field 1" "State" !insertmacro MUI_INSTALLOPTIONS_READ $SERVER_INSTALL "SelInst3Mode.ini" "Field 2" "State" !insertmacro MUI_INSTALLOPTIONS_READ $DESKTOP_INSTALL "SelInst3Mode.ini" "Field 6" "State" ;Server installation was selected intcmp $SERVER_INSTALL 1 SERVER DESKTOP SERVER: Call ServerParameter_show goto END DESKTOP: intcmp $DESKTOP_INSTALL 1 DESKTOP2 END DESKTOP2: Call DesktopParameter_show goto END END: FunctionEnd ;-------------------------------- ; Function called when entering the custom page ServerParameter Function ServerParameter_show intcmp $SERVER_INSTALL 0 END MessageBox '_K !insertmacro MUI_HEADER_TEXT "$(TEXT_SERVERPARAMETER_TITLE)" "$(TEXT_SERVERPARAMETER_SUBTITLE)" !insertmacro MUI_INSTALLOPTIONS_DISPLAY "ServerParameter.ini" END: FunctionEnd ;-------------------------------- ; Function called when entering the custom page ServerParameter Function ServerParameter_leave !insertmacro MUI_INSTALLOPTIONS_READ $DB_SERVER_NAME "ServerParameter.ini" "Field 5" "State" !insertmacro MUI_INSTALLOPTIONS_READ $DB_PORT_NUMBER "ServerParameter.ini" "Field 6" "State" !insertmacro MUI_INSTALLOPTIONS_READ $DB_LOGIN "ServerParameter.ini" "Field 7" "State" !insertmacro MUI_INSTALLOPTIONS_READ $DB_PWD "ServerParameter.ini" "Field 8" "State" !insertmacro MUI_INSTALLOPTIONS_READ $NET_PATH "ServerParameter.ini" "Field 11" "State" POP $R9 Strcmp $DB_SERVER_NAME "" DB_SERVER_NAME_EMPTY DB_SERVER_VALID DB_PORT_NUMBER_CHECK: Strcmp $DB_PORT_NUMBER "" DB_PORT_NUMBER_EMPTY 0 DB_LOGIN_CHECK: Strcmp $DB_LOGIN "" DB_LOGIN_EMPTY 0 DB_PWD_CHECK: Strcmp $DB_PWD "" DB_PWD_EMPTY 0 NET_PATH_CHECK: strcmp $NET_PATH "" NET_PATH_EMPTY END DB_SERVER_NAME_EMPTY: MessageBox MB_OK|MB_ICONSTOP "IP Address field can not be empty!" goto AGAIN DB_PORT_NUMBER_EMPTY: MessageBox MB_OK|MB_ICONSTOP "Server Port field can not be empty!" goto AGAIN DB_LOGIN_EMPTY: MessageBox MB_OK|MB_ICONSTOP "Login field can not be empty!" goto AGAIN DB_PWD_EMPTY: MessageBox MB_OK|MB_ICONSTOP "Password field can not be empty!" goto AGAIN WRONG_DB_SERVER: MessageBox MB_OK|MB_ICONSTOP "IP address: $DB_SERVER_NAME does not match an existing server!" goto AGAIN NET_PATH_EMPTY: MessageBox MB_OK|MB_ICONSTOP "Photos folder can not be empty" goto AGAIN AGAIN: Abort DB_SERVER_VALID: ;testing the content of the IP Address i.e. numbers and dot Push "0123456789." Push $DB_SERVER_NAME Call StrCSpnReverse Pop $R0 StrCmp $R0 "" +3 MessageBox MB_OK|MB_ICONEXCLAMATION 'String contains invalid character (only number and . are authorised)' goto AGAIN ;after testing the content of the IP address testing the validity of it at least 3 dots !insertmacro IndexOf $R0 $DB_SERVER_NAME "." strcpy $R1 0 strcmp $R0 -1 BAD_SYNTAX LOOP BAD_SYNTAX: MessageBox MB_OK|MB_ICONSTOP "IP Address format not recognised!" goto AGAIN LOOP: IntOp $R1 $R1 + 1 strcmp $R1 3 DB_PORT_NUMBER_CHECK strcpy $R2 $DB_SERVER_NAME "" $R0 !insertmacro IndexOf $R0 $DB_SERVER_NAME "." strcmp $R0 -1 BAD_SYNTAX LOOP END: nsExec::ExecToStack /OEM /TIMEOUT=5000 '"$EXEDIR\ping.exe " $DB_SERVER_NAME' POP $0 ;MathMessageBox MB_OK "ping returned $0" Strcmp $0 0 MYSQL_TEST WRONG_DB_SERVER MYSQL_TEST: nsExec::ExecToStack /OEM '"$EXEDIR\mysql.exe" -h$DB_SERVER_NAME -u$DB_LOGIN -p$DB_PWD -P$DB_PORT_NUMBER' POP $0 strcmp $0 0 MYSQL_OK MYSQL_NOTOK MYSQL_OK: goto CONTINUE MYSQL_NOTOK: strcmp $R9 3 0 MessageBox MB_OK "One or more entry are bad! (wrong port number OR wrong login OR wrong Password) Please re type them" IntOp $R9 $R9 + 1 goto AGAIN CONTINUE: FunctionEnd ;-------------------------------- ; Function called when entering the custom page DesktopParameter Function DesktopParameter_show intcmp $DESKTOP_INSTALL 0 END !insertmacro MUI_HEADER_TEXT "$(TEXT_DESKTOPPARAMETER_TITLE)" "$(TEXT_DESKTOPPARAMETER_SUBTITLE)" !insertmacro MUI_INSTALLOPTIONS_DISPLAY "DesktopParameter.ini" END: FunctionEnd ;-------------------------------- ; Function called when entering the custom page DesktopParameter Function DesktopParameter_leave !insertmacro MUI_INSTALLOPTIONS_READ $DB_SERVER_NAME "DesktopParameter.ini" "Field 3" "State" !insertmacro MUI_INSTALLOPTIONS_READ $DB_PORT_NUMBER "DesktopParameter.ini" "Field 4" "State" !insertmacro MUI_INSTALLOPTIONS_READ $NET_PATH "DesktopParameter.ini" "Field 6" "State" POP $R9 Strcmp $DB_SERVER_NAME "" DB_SERVER_NAME_EMPTY DB_SERVER_VALID DB_PORT_NUMBER_CHECK: Strcmp $DB_PORT_NUMBER "" DB_PORT_NUMBER_EMPTY 0 NET_PATH_CHECK: strcmp $NET_PATH "" NET_PATH_EMPTY END DB_SERVER_NAME_EMPTY: MessageBox MB_OK|MB_ICONSTOP "IP Address field can not be empty!" goto AGAIN DB_PORT_NUMBER_EMPTY: MessageBox MB_OK|MB_ICONSTOP "Server Port field can not be empty!" goto AGAIN WRONG_DB_SERVER: MessageBox MB_OK|MB_ICONSTOP "IP address: $DB_SERVER_NAME does not match an existing server!" goto AGAIN NET_PATH_EMPTY: MessageBox MB_OK|MB_ICONSTOP "Photos folder can not be empty" goto AGAIN AGAIN: Abort DB_SERVER_VALID: ;testing the content of the IP Address i.e. numbers and dot Push "0123456789." Push $DB_SERVER_NAME Call StrCSpnReverse Pop $R0 StrCmp $R0 "" +3 MessageBox MB_OK|MB_ICONEXCLAMATION 'String contains invalid character (only number and . are authorised)' goto AGAIN ;after testing the content of the IP address testing the validity of it at least 3 dots !insertmacro IndexOf $R0 $DB_SERVER_NAME "." strcpy $R1 0 strcmp $R0 -1 BAD_SYNTAX LOOP BAD_SYNTAX: MessageBox MB_OK|MB_ICONSTOP "IP Address format not recognised!" goto AGAIN LOOP: IntOp $R1 $R1 + 1 strcmp $R1 3 DB_PORT_NUMBER_CHECK strcpy $R2 $DB_SERVER_NAME "" $R0 !insertmacro IndexOf $R0 $DB_SERVER_NAME "." strcmp $R0 -1 BAD_SYNTAX LOOP END: nsExec::ExecToStack /OEM /TIMEOUT=5000 '"$EXEDIR\ping.exe " $DB_SERVER_NAME' POP $0 ;MathMessageBox MB_OK "ping returned $0" Strcmp $0 0 MYSQL_TEST WRONG_DB_SERVER MYSQL_TEST: nsExec::ExecToStack /OEM '"$EXEDIR\mysql.exe" -h$DB_SERVER_NAME -umgis -pmgis -P$DB_PORT_NUMBER' POP $0 strcmp $0 0 MYSQL_OK MYSQL_NOTOK MYSQL_OK: goto CONTINUE MYSQL_NOTOK: strcmp $R9 3 0 MessageBox MB_OK "MGIS is not installed on this server. Please install first the database on this server by using the network SERVER installation." IntOp $R9 $R9 + 1 goto AGAIN CONTINUE: FunctionEnd ;-------------------------------- ;Pages !insertmacro linefind !insertmacro WordReplace ;Install Pages !insertmacro MUI_PAGE_WELCOME !insertmacro MUI_PAGE_LICENSE $(MUILicense) ; My custom pages Page custom SelInstMode_show SelInstMode_leave Page custom ServerParameter_show ServerParameter_leave Page custom DesktopParameter_show DesktopParameter_leave !insertmacro MUI_PAGE_COMPONENTS ;Start Menu Folder Page Configuration !define MUI_STARTMENUPAGE_REGISTRY_ROOT "HKCU" !define MUI_STARTMENUPAGE_REGISTRY_KEY "Software\MGIS 3" !define MUI_STARTMENUPAGE_REGISTRY_VALUENAME "Start Menu Folder" !insertmacro MUI_PAGE_STARTMENU Application $STARTMENU_FOLDER !insertmacro MUI_PAGE_INSTFILES !insertmacro MUI_PAGE_FINISH ;Uninstall pages !insertmacro MUI_UNPAGE_WELCOME !insertmacro MUI_UNPAGE_CONFIRM !insertmacro MUI_UNPAGE_COMPONENTS !insertmacro MUI_UNPAGE_DIRECTORY !insertmacro MUI_UNPAGE_INSTFILES !insertmacro MUI_UNPAGE_FINISH ;-------------------------------- ;Languages !insertmacro MUI_LANGUAGE "English" # first language is the default language !insertmacro MUI_LANGUAGE "French" !insertmacro MUI_LANGUAGE "Spanish" ;-------------------------------- ;License Language String LicenseLangString MUILicense ${LANG_ENGLISH} "LicenseEN.txt" LicenseLangString MUILicense ${LANG_FRENCH} "LicenseFR.txt" LicenseLangString MUILicense ${LANG_SPANISH} "LicenseSP.txt" ;-------------------------------- ;Reserve Files ;These files should be inserted before other files in the data block ;Keep these lines before any File command ;Only for solid compression (by default, solid compression is enabled for BZIP2 and LZMA) !insertmacro MUI_RESERVEFILE_LANGDLL ReserveFile "SelInst3Mode.ini" ReserveFile "ServerParameter.ini" ReserveFile "DesktopParameter.ini" !insertmacro MUI_RESERVEFILE_INSTALLOPTIONS ;-------------------------------- ;Installer Sections SectionGroup /e "Application" SecGrpApp Section /o "JAVA Runtime Edition" SecJAVA ExecWait 'jre-1_5_0_06-windows-i586-p.exe' $0 DetailPrint "JAVA installation returned $0" SectionEnd Section !Application SecMgis SectionIn RO SetOutPath "$PROGRAMFILES\MGISV3A" ; is it a local install? intcmp $LOCAL_INSTALL 0 SERVER_INSTALL ;Push "PATH" ;Push "C:\Program Files\mgisv3a\MySQL\MySQLServer5_0\bin" ;Call AddToEnvVar Call GetWindowsVersion ;Testing Windows version to avoid installing MySQL as service on Windows 98!!! Pop $R0 StrCmp $R0 '98' NOSRVC ;We are installing MGIS on Windows98 StrCmp $R0 'ME' NOSRVC ;We are installing MGIS on Windows Millenium StrCmp $R0 '2000' INSTALSRVC ;We are installing MGIS on Windows 2000 StrCmp $R0 'XP' INSTALSRVC ;We are installing MGIS on Windows XP StrCmp $R0 'Vista' INSTALSRVC ;We are installing MGIS on Windows Vista INSTALSRVC: ;Installing MySQL files before launching service nsExec::ExecToLog '"$EXEDIR\7za.exe" x -y "$EXEDIR\mysqlmgis.zip" -o"e:\temp"' pop $0 IntCmp $0 0 0 EXIT_ZIPFAILURE ;Is MySQL5mgis service already existing? services::GetServiceNameFromDisplayName 'MySQL5mgis' pop $0 ; Pops a string off of the stack into user variable (i.e. $0) IntCmp $0 1 EXIT ;If MySQL5mgis service already exists then go away it is already done ;If MySQL5mgis service not installed then install it nsSCM::Install "MySQL5mgis" "MySQL5mgis" 16 3 "$\"C:\Program Files\mgisv3a\MySQL\MySQLServer5_0\bin\mysqld-nt$\" $\"--defaults-file=C:\Program Files\mgisv3a\MySQL\MySQLServer5_0\my.ini$\" MySQL5mgis" "" "" "" "" Pop $0 IntCmp $0 0 EXIT ;If MySQL5mgis service installed I go to STARTSVCMYSQL IntCmp $0 1 ERRORINSTALLSVCMYSQL ;If MySQL5mgis service installed I go to ERRORINSTALLSVCMYSQL go away ERRORINSTALLSVCMYSQL: MessageBox MB_OK|MB_ICONINFORMATION '$0 when attempting to install MySQL5mgis service. Please contact provider of the application.' IntCmp $0 1 FAILUREEXIT FAILUREEXIT: MessageBox MB_OK|MB_ICONINFORMATION 'MGIS INSTALLATION FAILURE' IntCmp $0 0 EXIT NOSRVC: ;ExecWait 'mgisv3a98.exe' $0 ;DetailPrint "mgis installation returned $0" EXIT_ZIPFAILURE: GoTo END EXIT_SERVERFAILURE: GoTo END SERVER_INSTALL: ;Here we load the database into the server previously gave ;nsExec::ExecToLog 'cmd /C $EXEDIR\mysql.exe -h$DB_SERVER_NAME -P$DB_PORT_NUMBER -u$DB_LOGIN -p$DB_PWD --default-character-set=utf8 < "$EXEDIR\MGIS.sql"' ;pop $0 ;IntCmp $0 0 0 EXIT_SERVERFAILURE ;Here we grant access to the MGIS database created once upon a time... ;nsExec::ExecToLog 'cmd /C $EXEDIR\mysql.exe -h$DB_SERVER_NAME -P$DB_PORT_NUMBER -u$DB_LOGIN -p$DB_PWD < "$EXEDIR\MGISgrant.sql"' ;pop $0 ;IntCmp $0 0 0 EXIT_SERVERFAILURE ;nsExec::ExecToStack /OEM '"$EXEDIR\mysql.exe" -h$DB_SERVER_NAME -umgis -pmgis -P$DB_PORT_NUMBER' ;POP $0 ;strcmp $0 0 END EXIT_SERVERFAILURE ;Store IP Address of the DB server WriteRegStr HKCU "Software\MGIS 3" "DBserver" $DB_SERVER_NAME ;Store installation folder WriteRegStr HKCU "Software\MGIS 3" "DBPort" $DB_PORT_NUMBER ;Store installation folder WriteRegStr HKCU "Software\MGIS 3" "DBLogin" $DB_LOGIN ;Store installation folder WriteRegStr HKCU "Software\MGIS 3" "DBPwd" $DB_PWD ;Installing application files ;nsExec::ExecToLog '"$EXEDIR\7za.exe" x -y "$EXEDIR\mgisv3a.zip" -o"e:\temp"' ;pop $0 ;IntCmp $0 0 END EXIT_ZIPFAILURE ;TODO ;launch the process to install the database on the server ;launch the process to set a specific account to acces the database ;modify the hibernate.config.xml file to connect to the server. EXIT: ;Installing application files ;nsExec::ExecToLog '"$EXEDIR\7za.exe" x -y "$EXEDIR\mgisv3a.zip" -o"e:\temp"' ;pop $0 ;IntCmp $0 0 0 EXIT_ZIPFAILURE !insertmacro MUI_STARTMENU_WRITE_BEGIN Application ;Create shortcuts CreateDirectory "$SMPROGRAMS\$STARTMENU_FOLDER" CreateShortCut "$SMPROGRAMS\$STARTMENU_FOLDER\Uninstall.lnk" "$INSTDIR\Uninstall.exe" CreateShortCut "$SMPROGRAMS\$STARTMENU_FOLDER\mgis.lnk" "$INSTDIR\mgis.bat" !insertmacro MUI_STARTMENU_WRITE_END ;Store Display Name of the app WriteRegStr HKCU "Software\MGIS 3" "DisplayName" "${APPLICATION_FULLNAME}" ;Store Version of the app WriteRegStr HKCU "Software\MGIS 3" "Version" "${VERSION}" ;Store installation folder WriteRegStr HKCU "Software\MGIS 3" "InstallFolder" $INSTDIR ;Store the uninstaller WriteRegStr HKCU "Software\MGIS 3" "UninstallString" "$INSTDIR\uninstall.exe" ;Store the uninstaller WriteRegStr HKCU "Software\MGIS 3" "DefaultIcon" "$INSTDIR\MGIS.ico" ;Create uninstaller WriteUninstaller "$INSTDIR\Uninstall.exe" ;Add bin folder of MySQL to PATH Push "PATH" Push "C:\Program Files\MGISV3A\MySQL\MySQLServer5_0\bin" Call AddToEnvVar ;Update the hibernate.cfg.xml file with the new server StrCpy $R0 0 ${LineFind} "$INSTDIR\classes\hibernate.cfg.xml" "$INSTDIR\classes\hibernate.cfg.xml" "1:-1" "ChangeServerName" ifErrors 0 +2 MessageBox MB_OK "Error" IDOK +2 MessageBox MB_OK "Changed lines=$R0" END: SectionEnd SectionGroupEnd SectionGroup /e "Application" SecGrpMis Section /o "Photos" SecPhotos ;nsExec::ExecToLog '"$EXEDIR\7za.exe" x -y "$EXEDIR\photos.zip" -o"e:\temp"' Call FindCDROMLetter StrLen $R1 $CDROM_LETTER StrCmp $R1 3 UNZIP_OK Push -1 DetailPrint "Hargh it is not working!" Pop $1 IntCmp $1 -1 EXIT_UNZIP UNZIP_OK: ;Write CDROM_PHOTOPATH in mgis.properties file ;Extract the letter of the cdrom to write it under good format in the mgis.properties file strcpy $9 $CDROM_LETTER 1 ${WriteINILargeStr_Open} "$INSTDIR\mgis.properties" "SETUP" "CDROM_PHOTOPATH" ${WriteINILargeStr} $9 ${WriteINILargeStr} "\:\\photos\\" ${WriteINILargeStr_Close} EXIT_UNZIP: SectionEnd SectionGroupEnd ;-------------------------------- ;Installer Functions Function .onInit newadvsplash::show 500 1000 000 -1 "$EXEDIR\logo_bioversity_big.jpg" newadvsplash::show 1000 500 1000 -1 "$EXEDIR\bioversity tag.jpg" ;Setup the language for the install !insertmacro MUI_LANGDLL_DISPLAY ;extract ini file(s) for custom page(s) !insertmacro MUI_INSTALLOPTIONS_EXTRACT "SelInst3Mode.ini" !insertmacro MUI_INSTALLOPTIONS_EXTRACT "ServerParameter.ini" !insertmacro MUI_INSTALLOPTIONS_EXTRACT "DesktopParameter.ini" StrCpy $STARTMENU_FOLDER ${APPLICATION_NAME} ;Prevent installer running twice SYSTEM::Call 'kernel32::CreateMutexA(i 0, i 0, t "myMutex") i .r1 ?e' Pop $R0 StrCmp $R0 0 +3 MessageBox MB_OK|MB_ICONEXCLAMATION "MGIS installer is already running." Abort Call LocateJVM StrCmp "" $JAVA_INSTALLATION_MSG Success Failure Success: SectionGetFlags "${SecJAVA}" $0 IntOp $0 $0 & ${SECTION_OFF} SectionSetFlags "${SecJAVA}" $0 StrCmp "" "$JAVA_INSTALLATION_MSG" NEXTTest Failure: SectionGetFlags "${SecJAVA}" $0 IntOp $0 $0 | ${SF_SELECTED} SectionSetFlags "${SecJAVA}" $0 NEXTTest: ;Test of MGIS presence ;ReadRegStr $MGIS_VER HKCU "Software\MGIS 3" Version ;StrCmp "" "$MGIS_VER" MGISNotPresent MGISPresent MGISPresent: ;MessageBox MB_OK|MB_ICONINFORMATION "MGIS is already installed on this computer. You should uninstall the installed version before to install a new one." ;Abort MGISNotPresent: FunctionEnd ;-------------------------------- ;Descriptions for Install ;USE A LANGUAGE STRING IF YOU WANT YOUR DESCRIPTIONS TO BE LANGUAGE SPECIFIC ;Assign descriptions to custom pages SelInstMode LangString TEXT_SELINSTMODE_TITLE ${LANG_ENGLISH} "Installation Mode" LangString TEXT_SELINSTMODE_TITLE ${LANG_FRENCH} "Mode d'installation" LangString TEXT_SELINSTMODE_TITLE ${LANG_SPANISH} "Installation Mode" LangString TEXT_SELINSTMODE_SUBTITLE ${LANG_ENGLISH} "" LangString TEXT_SELINSTMODE_SUBTITLE ${LANG_FRENCH} "" LangString TEXT_SELINSTMODE_SUBTITLE ${LANG_SPANISH} "" ;Assign descriptions to custom pages ServerParameter LangString TEXT_SERVERPARAMETER_TITLE ${LANG_ENGLISH} "Server parameters" LangString TEXT_SERVERPARAMETER_TITLE ${LANG_FRENCH} "Paramètres du serveur" LangString TEXT_SERVERPARAMETER_TITLE ${LANG_SPANISH} "Server parameters" LangString TEXT_SERVERPARAMETER_SUBTITLE ${LANG_ENGLISH} "Please fill the 5 fields" LangString TEXT_SERVERPARAMETER_SUBTITLE ${LANG_FRENCH} "Veuillez remplir les 5 champs" LangString TEXT_SERVERPARAMETER_SUBTITLE ${LANG_SPANISH} "Please fill the 5 fields" ;Assign descriptions to custom pages DesktopParameter LangString TEXT_DESKTOPPARAMETER_TITLE ${LANG_ENGLISH} "Server parameters" LangString TEXT_DESKTOPPARAMETER_TITLE ${LANG_FRENCH} "Paramètres du serveur" LangString TEXT_DESKTOPPARAMETER_TITLE ${LANG_SPANISH} "Server parameters" LangString TEXT_DESKTOPPARAMETER_SUBTITLE ${LANG_ENGLISH} "Please fill the 3 fields" LangString TEXT_DESKTOPPARAMETER_SUBTITLE ${LANG_FRENCH} "Veuillez remplir les 3 champs" LangString TEXT_DESKTOPPARAMETER_SUBTITLE ${LANG_SPANISH} "Please fill the 3 fields" ;Assign descriptions to Group sections LangString Desc_SecGrpApp ${LANG_ENGLISH} "Required for installing the application" LangString Desc_SecGrpApp ${LANG_FRENCH} "Requis pour installer l'application" LangString Desc_SecGrpApp ${LANG_SPANISH} "Required for installing the application" LangString Desc_SecGrpMis ${LANG_ENGLISH} "Options of the application" LangString Desc_SecGrpMis ${LANG_FRENCH} "Options de l'application" LangString Desc_SecGrpMis ${LANG_SPANISH} "Options of the application" ;Assign descriptions to sections LangString Desc_SecJAVA ${LANG_ENGLISH} "Install JAVA Runtime Edition" LangString Desc_SecJAVA ${LANG_FRENCH} "Installe l'edition runtime de JAVA" LangString Desc_SecJAVA ${LANG_SPANISH} "Install JAVA Runtime Edition" LangString Desc_SecMgis ${LANG_ENGLISH} "Install MGIS application" LangString Desc_SecMgis ${LANG_FRENCH} "Installe l'application MGIS" LangString Desc_SecMgis ${LANG_SPANISH} "Install MGIS application" LangString Desc_Secphotos ${LANG_ENGLISH} "Photos will be copied on the computer" LangString Desc_SecPhotos ${LANG_FRENCH} "Les photos seront copiées sur l'ordinateur" LangString Desc_SecPhotos ${LANG_SPANISH} "Photos will be copied on the computer" !insertmacro MUI_FUNCTION_DESCRIPTION_BEGIN !insertmacro MUI_DESCRIPTION_TEXT ${SecGrpApp} $(Desc_SecGrpApp) !insertmacro MUI_DESCRIPTION_TEXT ${SecJAVA} $(Desc_SecJAVA) !insertmacro MUI_DESCRIPTION_TEXT ${SecMgis} $(Desc_SecMgis) !insertmacro MUI_DESCRIPTION_TEXT ${SecGrpMis} $(Desc_SecGrpMis) !insertmacro MUI_DESCRIPTION_TEXT ${SecPhotos} $(Desc_SecPhotos) !insertmacro MUI_FUNCTION_DESCRIPTION_END ;-------------------------------- ;Uninstaller Section SectionGroup /e "Un.Application" UnSecGrpApp Section "Un.MGIS Application" UnSecMgis SectionIn RO ;Is MySQL5mgis already existing? services::GetServiceNameFromDisplayName 'MySQL5mgis' pop $0 ; Pops a string off of the stack into user variable (i.e. $0) IntCmp $0 1 EXISTS ;If MySQL5mgis service already exists then ok IntCmp $0 0 REMOVESVCMYSQL_OK EXISTS: nsSCM::QueryStatus "MySQL5mgis" pop $0 pop $1 IntCmp $1 4 STOPSVCMYSQL ;If the service is running I go to STOPSVCMYSQL IntCmp $1 1 REMOVESVCMYSQL ;If the service is NOT running I go to REMOVESVCMYSQL IntCmp $1 2 REMOVESVCMYSQL ;If the service is NOT running I go to REMOVESVCMYSQL IntCmp $1 3 REMOVESVCMYSQL ;If the service is NOT running I go to REMOVESVCMYSQL IntCmp $1 5 REMOVESVCMYSQL ;If the service is NOT running I go to REMOVESVCMYSQL IntCmp $1 6 REMOVESVCMYSQL ;If the service is NOT running I go to REMOVESVCMYSQL IntCmp $1 7 REMOVESVCMYSQL ;If the service is NOT running I go to REMOVESVCMYSQL STOPSVCMYSQL: nsSCM::Stop "MySQL5mgis" pop $0 IntCmp $0 0 REMOVESVCMYSQL ; If MySQL5mgis stopped then I go to REMOVESVCMYSQL IntCmp $0 1 ERRORSTOPSVCMYSQL ; If MySQL5mgis NOT stopped then I go to ERRORSTOPSVCMYSQL REMOVESVCMYSQL: ;If MySQL5mgis service not installed then I install it nsSCM::Remove "MySQL5mgis" pop $0 IntCmp $0 0 REMOVESVCMYSQL_OK ;If MySQL5mgis service uninstalled I go to REMOVESVCMYSQL_OK IntCmp $0 1 FAILUREEXIT ;If MySQL5mgis service NOT uninstalled I go to FAILUREEXIT ERRORSTOPSVCMYSQL: MessageBox MB_OK|MB_ICONINFORMATION '$0 when attempting to Stop MySQL5mgis service. Please contact provider of the application.' IntCmp $0 1 FAILUREEXIT FAILUREEXIT: REMOVESVCMYSQL_OK: !insertmacro MUI_STARTMENU_GETFOLDER Application $MUI_TEMP Delete "$SMPROGRAMS\$MUI_TEMP\Uninstall.lnk" Delete "$SMPROGRAMS\$MUI_TEMP\mgis.lnk" ;Delete empty start menu parent diretories StrCpy $MUI_TEMP "$SMPROGRAMS\$MUI_TEMP" startMenuDeleteLoop: ClearErrors RMDir $MUI_TEMP GetFullPathName $MUI_TEMP "$MUI_TEMP\.." IfErrors startMenuDeleteLoopDone StrCmp $MUI_TEMP $SMPROGRAMS startMenuDeleteLoopDone startMenuDeleteLoop startMenuDeleteLoopDone: DeleteRegKey /ifempty HKCU "Software\MGIS 3" SetOutPath $Temp RMDir /r "$INSTDIR" SectionEnd SectionGroupEnd ;-------------------------------- ;Uninstaller Functions Function un.onInit ;retrieving the language of the install !insertmacro MUI_UNGETLANGUAGE FindWindow $0 "${WNDCLASS}" "${WNDTITLE}" StrCmp $0 0 continueunInstall MessageBox MB_ICONSTOP|MB_OK "The application you are trying to remove is running. Close it and try again." Abort continueunInstall: FunctionEnd ;-------------------------------- ;Descriptions for Uninstall ;Assign descriptions to Group sections LangString Desc_UnSecGrpApp ${LANG_ENGLISH} "Required for Uninstalling the application" LangString Desc_UnSecGrpApp ${LANG_FRENCH} "Requis pour Désinstaller l'application" LangString Desc_UnSecGrpApp ${LANG_SPANISH} "Required for Uninstalling the application" ;Assign descriptions to sections LangString Desc_UnSecMgis ${LANG_ENGLISH} "Uninstall MGIS application" LangString Desc_UnSecMgis ${LANG_FRENCH} "Désinstalle l'application MGIS" LangString Desc_UnSecMgis ${LANG_SPANISH} "Uninstall MGIS application" !insertmacro MUI_UNFUNCTION_DESCRIPTION_BEGIN !insertmacro MUI_DESCRIPTION_TEXT ${UnSecGrpApp} $(Desc_UnSecGrpApp) !insertmacro MUI_DESCRIPTION_TEXT ${UnSecMgis} $(Desc_UnSecMgis) !insertmacro MUI_UNFUNCTION_DESCRIPTION_END ;-------------------------------- ; GetWindowsVersion ; ; Based on Yazno's function, http://yazno.tripod.com/powerpimpit/ ; Updated by Joost Verburg ; ; Returns on top of stack ; ; Windows Version (95, 98, ME, NT x.x, 2000, XP, 2003, Vista) ; or ; '' (Unknown Windows Version) ; ; Usage: ; Call GetWindowsVersion ; Pop $R0 ; ; at this point $R0 is "NT 4.0" or whatnot Function GetWindowsVersion Push $R0 Push $R1 ClearErrors ReadRegStr $R0 HKLM \ "SOFTWARE\Microsoft\Windows NT\CurrentVersion" CurrentVersion IfErrors 0 lbl_winnt ; we are not NT ReadRegStr $R0 HKLM \ "SOFTWARE\Microsoft\Windows\CurrentVersion" VersionNumber StrCpy $R1 $R0 1 StrCmp $R1 '4' 0 lbl_error StrCpy $R1 $R0 3 StrCmp $R1 '4.0' lbl_win32_95 StrCmp $R1 '4.9' lbl_win32_ME lbl_win32_98 lbl_win32_95: StrCpy $R0 '95' Goto lbl_done lbl_win32_98: StrCpy $R0 '98' Goto lbl_done lbl_win32_ME: StrCpy $R0 'ME' Goto lbl_done lbl_winnt: StrCpy $R1 $R0 1 StrCmp $R1 '3' lbl_winnt_x StrCmp $R1 '4' lbl_winnt_x StrCpy $R1 $R0 3 StrCmp $R1 '5.0' lbl_winnt_2000 StrCmp $R1 '5.1' lbl_winnt_XP StrCmp $R1 '5.2' lbl_winnt_2003 StrCmp $R1 '6.0' lbl_winnt_vista lbl_error lbl_winnt_x: StrCpy $R0 "NT $R0" 6 Goto lbl_done lbl_winnt_2000: Strcpy $R0 '2000' Goto lbl_done lbl_winnt_XP: Strcpy $R0 'XP' Goto lbl_done lbl_winnt_2003: Strcpy $R0 '2003' Goto lbl_done lbl_winnt_vista: Strcpy $R0 'Vista' Goto lbl_done lbl_error: Strcpy $R0 '' lbl_done: Pop $R1 Exch $R0 FunctionEnd ;-------------------------------- ; FindCDROMLetter Function FindCDROMLetter # Enumerate CD-ROMs loop: cdrom::FindNext /NOUNLOAD .r0 Strcpy $CDROM_LETTER $0 cdrom::FindClose /* #Open CD-ROM door cdrom::Open "$0" .R0 MessageBox MB_OK "cdrom::OpenCD$\n$\n\ Errorlevel: [$R0]" # Close CD-ROM door cdrom::Close "$0" .R0 MessageBox MB_OK "cdrom::CloseCD$\n$\n\ Errorlevel: [$R0]" # Get CD-ROM status cdrom::Status "$0" .R0 MessageBox MB_OK "cdrom::StatusCD$\n$\n\ Errorlevel: [$R0]" # Get CD-ROM volume name cdrom::VolumeName "$0" .R0 MessageBox MB_OK "cdrom::VolumeName$\n$\n\ Errorlevel: [$R0]" # Get CD-ROM volume serial number cdrom::VolumeSerialNumber "$0" .R0 MessageBox MB_OK "cdrom::VolumeSerialNumber$\n$\n\ Errorlevel: [$R0]" */ FunctionEnd ;find the index of a character in a string from left (IndexOf) ;For the default behaviour of StrCpy, IndexOf returns the character index as zero-based Function IndexOf Exch $R0 Exch Exch $R1 Push $R2 Push $R3 StrCpy $R3 $R0 StrCpy $R0 -1 IntOp $R0 $R0 + 1 StrCpy $R2 $R3 1 $R0 StrCmp $R2 "" +2 StrCmp $R2 $R1 +2 -3 StrCpy $R0 -1 Pop $R3 Pop $R2 Pop $R1 Exch $R0 FunctionEnd ;This function (StrCSpn) checks a string for invalid characters on a list. ;the first invalid character found is returned, ;else null ("") is returned if no invalid characters are found. Function StrCSpn Exch $R0 ; string to check Exch Exch $R1 ; string of chars Push $R2 ; current char Push $R3 ; current char Push $R4 ; char loop Push $R5 ; char loop StrCpy $R4 -1 NextChar: StrCpy $R2 $R1 1 $R4 IntOp $R4 $R4 - 1 StrCmp $R2 "" StrOK StrCpy $R5 -1 NextCharCheck: StrCpy $R3 $R0 1 $R5 IntOp $R5 $R5 - 1 StrCmp $R3 "" NextChar StrCmp $R3 $R2 0 NextCharCheck StrCpy $R0 $R2 Goto Done StrOK: StrCpy $R0 "" Done: Pop $R5 Pop $R4 Pop $R3 Pop $R2 Pop $R1 Exch $R0 FunctionEnd ;This function (StrCSpnReverse) checks a string for invalid characters not on a list. Function StrCSpnReverse Exch $R0 ; string to check Exch Exch $R1 ; string of chars Push $R2 ; current char Push $R3 ; current char Push $R4 ; char loop Push $R5 ; char loop StrCpy $R4 -1 NextCharCheck: StrCpy $R2 $R0 1 $R4 IntOp $R4 $R4 - 1 StrCmp $R2 "" StrOK StrCpy $R5 -1 NextChar: StrCpy $R3 $R1 1 $R5 IntOp $R5 $R5 - 1 StrCmp $R3 "" +2 StrCmp $R3 $R2 NextCharCheck NextChar StrCpy $R0 $R2 Goto Done StrOK: StrCpy $R0 "" Done: Pop $R5 Pop $R4 Pop $R3 Pop $R2 Pop $R1 Exch $R0 FunctionEnd Function DirectoryShow StrCmp $9 "0" AppDirectoryPage StrCmp $9 "1" DataDirectoryPage AppDirectoryPage: StrCpy $9 "1" !insertmacro MUI_INNERDIALOG_TEXT 1041 "Destination Folder" !insertmacro MUI_INNERDIALOG_TEXT 1019 "$PROGRAMFILES\${MUI_PRODUCT}\" !insertmacro MUI_INNERDIALOG_TEXT 1006 "Setup will install ${MUI_PRODUCT} in the following folder.$\r$\n$\r$\nTo install in a different folder, click Browse and select another folder. Click Next to continue." Goto EndDirectoryShow DataDirectoryPage: StrCpy $9 "2" !insertmacro MUI_HEADER_TEXT "Choose Data Location" "Choose the folder in which to install ${MUI_PRODUCT} - Data Files." !insertmacro MUI_INNERDIALOG_TEXT 1041 "Data Destination Folder" !insertmacro MUI_INNERDIALOG_TEXT 1019 "$INSTDIR\Data\" !insertmacro MUI_INNERDIALOG_TEXT 1006 "Setup will install ${MUI_PRODUCT} - Data Files in the following folder.$\r$\n$\r$\nTo install in a different folder, click Browse and select another folder. Click Install to start the installation." EndDirectoryShow: FunctionEnd Function DirectoryLeave StrCmp $9 "1" SaveInstallDir StrCmp $9 "2" SaveDatabaseDir Goto EndDirectoryLeave SaveInstallDir: StrCpy $2 $INSTDIR Goto EndDirectoryLeave SaveDatabaseDir: StrCpy $3 $INSTDIR EndDirectoryLeave: FunctionEnd ;-------------------------------- ;AUTHOR: Ashwin Jayaprakash ;WEBSITE: http://www.JavaForU.com ;-------------------------------- Function LocateJVM ;Check for Java version and location Push $0 Push $1 ReadRegStr $JAVA_VER HKLM "SOFTWARE\JavaSoft\Java Runtime Environment" CurrentVersion StrCmp "" "$JAVA_VER" JavaNotPresent CheckJavaVer JavaNotPresent: StrCpy $JAVA_INSTALLATION_MSG "Java Runtime Environment is not installed on your computer. You need version 1.4 or newer to run this program." Goto Done CheckJavaVer: ReadRegStr $0 HKLM "SOFTWARE\JavaSoft\Java Runtime Environment\$JAVA_VER" JavaHome GetFullPathName /SHORT $JAVA_HOME "$0" StrCpy $0 $JAVA_VER 1 0 StrCpy $1 $JAVA_VER 1 2 StrCpy $JAVA_VER "$0$1" IntCmp 15 $JAVA_VER FoundCorrectJavaVer FoundCorrectJavaVer JavaVerNotCorrect FoundCorrectJavaVer: IfFileExists "$JAVA_HOME\bin\javaw.exe" 0 JavaNotPresent ;MessageBox MB_OK "Found Java: $JAVA_VER at $JAVA_HOME" Goto Done JavaVerNotCorrect: StrCpy $JAVA_INSTALLATION_MSG "The version of Java Runtime Environment installed on your computer is $JAVA_VER. Version 1.5 or newer is required to run this program." Done: Pop $1 Pop $0 FunctionEnd Function ChangeServerName StrCpy $1 $R9 DetailPrint '$DB_SERVER_NAME:$DB_PORT_NUMBER' ${WordReplace} '$R9' 'localhost:6808' '$DB_SERVER_NAME:$DB_PORT_NUMBER' '+' $R9 MessageBox MB_OK $1 MessageBox MB_OK $R9 StrCmp $1 $R9 +2 MessageBox MB_OK $0 MessageBox MB_OK $R0 IntOp $R0 $R0 + 1 ;$R0 count of changed lines Push $0 FunctionEnd