Custom Page - Not displaying
I am attempting to display a custom page in my installer but for some reason I cannot seem to get this to work. Interestingly this has worked using earlier versions of NSIS but since upgrade to the latest version it no longer works.
The custom page asks the user for various details and then calls a custom function that uses these details. The reason for this seperation is that the installer also supports a silent install mode where the necessary values are passed as command line parameters.
The following is an edited (but compilable) version of the script in question.
This is what I have in the DBSelection.ini file########################################################
TestCustomPage.exe"
>; Includes
>;########################################################
>!include "Sections.nsh"
>!include "MUI.nsh"
>; -------------------------------------------------------
;########################################################
>; General Settings
>;########################################################
>Name "${APPNAMEANDVERSION}"
>InstallDir "C:\TestCustomPage\"
OutFile "
; vars
!define APPNAME "Test Custom Page App"
!define APPNAMEANDVERSION "Test Custom Page App 1.0"
var SQL_DB_SERVERNAME
var SQL_DB_PASSWORD
var SQL_DB_USER
; -------------------------------------------------------
;########################################################
; Pages
;########################################################
!define MUI_ABORTWARNING
!insertmacro MUI_PAGE_WELCOME
!insertmacro MUI_PAGE_COMPONENTS
!insertmacro MUI_PAGE_INSTFILES
Page custom GetDbDetails
!insertmacro MUI_PAGE_FINISH
; -------------------------------------------------------
;########################################################
; Set languages
;########################################################
!insertmacro MUI_LANGUAGE "English"
!insertmacro MUI_RESERVEFILE_LANGDLL
; -------------------------------------------------------
;########################################################
; Section - Execute SQL Scripts
;########################################################
Section "Install Database Data" sec_db_data
LogSet on
DetailPrint 'Start - Installing SQL Scripts'
MessageBox MB_OK "In Section sec_db_data"
IfSilent silentInstallation end
silentInstallation:
StrCpy $SQL_DB_SERVERNAME "127.0.0.1"
StrCpy $SQL_DB_PASSWORD "sa"
StrCpy $SQL_DB_USER "xxxxxxxxxxx";
Call InstallDb
goto end
end:
DetailPrint 'End - Installing SQL Scripts'
SectionEnd
;--------------------------------------------------------
;########################################################
; Modern install section descriptions
;########################################################
!insertmacro MUI_FUNCTION_DESCRIPTION_BEGIN
!insertmacro MUI_DESCRIPTION_TEXT ${sec_db_data} "Install Database."
!insertmacro MUI_FUNCTION_DESCRIPTION_END
;--------------------------------------------------------
;########################################################
; CUSTOM GUI PAGE FUNCTION (DB Server Details)
;########################################################
Function GetDbDetails
MessageBox MB_OK "In Function GetDbDetails"
SectionGetFlags ${sec_db_data} $R0
IntOp $R0 $R0 & ${SF_SELECTED}
IntCmp $R0 ${SF_SELECTED} show
Abort
MessageBox MB_OK "Showing DB selection"
;;show the custom page
show:
!insertmacro MUI_INSTALLOPTIONS_EXTRACT "DBSelection.ini"
!insertmacro MUI_HEADER_TEXT "Database Details" "Enter database access details below."
!insertmacro MUI_INSTALLOPTIONS_DISPLAY "DBSelection.ini"
;;Get the entered values into vars
!insertmacro MUI_INSTALLOPTIONS_READ $SQL_DB_SERVERNAME "DBSelection.ini" "Field 2" "State"
!insertmacro MUI_INSTALLOPTIONS_READ $SQL_DB_USER "DBSelection.ini" "Field 4" "State"
!insertmacro MUI_INSTALLOPTIONS_READ $SQL_DB_PASSWORD "DBSelection.ini" "Field 6" "State"
;;call the install DB function
Call InstallDb
FunctionEnd
;--------------------------------------------------------
;########################################################
; FUNCTION Install DB
;########################################################
Function InstallDb
DetailPrint 'Checking for the presence of working SQL using given user details'
nsExec::ExecToStack 'osql.exe -S$SQL_DB_SERVERNAME -P$SQL_DB_PASSWORD -U$SQL_DB_USER -dmaster -Q"print 1"'
pop $R0
StrCmp $R0 "0" 0 sqlNotFound
DetailPrint 'SQL instance found lauching DB installation scripts'
nsExec::ExecToLog /TIMEOUT=5000 '$INSTDIR\SQLScripts\script_installer.bat $SQL_DB_SERVERNAME $SQL_DB_PASSWORD $SQL_DB_USER $INSTDIR\SqlScripts\ $INSTDIR\logs\SqlInstallLogs\ > $INSTDIR\Logs\SqlInstallLogs\ScriptInstaller.log'
goto end
sqlNotFound:
DetailPrint "SQL instance not found using given details, aborting SQL install process";
end:
FunctionEnd
;--------------------------------------------------------
>
[Settings]
NumFields=6
[Field 1]
Type=Label
Text=Database Server Name / IP
Left=0
Right=300
Top=10
Bottom=23
[Field 2]
Type=Text
State=127.0.0.1
Left=0
Right=300
Top=23
Bottom=36
[Field 3]
Type=Label
Text=SA Username
Left=0
Right=300
Top=54
Bottom=68
[Field 4]
Type=Text
State=SA
Left=0
Right=300
Top=68
Bottom=82
[Field 5]
Type=Label
Text=SA Password
Left=0
Right=300
Top=101
Bottom=115
[Field 6]
Type=Text
State=xxxxxxxxxxx
Left=0
Right=300
Top=116
Bottom=130
For testing purposes I threw a few message boxes in, and these all display with the exception of the one after the SectionGetFlags code in GetDbDetails function.
Can anybody tell me where I am going wrong here