views:

1290

answers:

2

I'm using Eclipse's create InstallOptions menu to create a custom INI page with radio-buttons for repackaging the Blackberry Desktop installer.

There are 2 sections for each type: "Internet" and "Enterprise".

I need a user to select 1 of the 2 options and depending on their selection, the page will carry over the selection chosen in the custom page, jump to the INSTFILES page, and continue onto the end.

I couldn't find any concrete documentation on getting INI pages to load in the script (I'm probably searching incorrectly), and then pass data from one page to the next (according to fields I guess?)

Any help is appreciated. Even if it's to tell me I'm blind and can't read a doc (though a link would help :) )

Here's the INI code:


; Auto-generated by EclipseNSIS InstallOptions Script Wizard
; Jul 29, 2009 5:42:56 PM

[Settings]
NumFields=7
Title=RIM BlackBerry Desktop 5.0 installation
CancelEnabled=1

[Field 1]
Type=RadioButton
Left=15
Top=28
Right=100
Bottom=38
Text=Internet
State=
Flags=NOTIFY

[Field 4]
Type=RadioButton
Left=15
Top=95
Right=100
Bottom=105
Text=Enterprise
Flags=NOTIFY

[Field 2]
Type=GroupBox
Left=0
Top=10
Right=300
Bottom=75
Text=

[Field 5]
Type=Label
Left=30
Top=42
Right=235
Bottom=52
Text=For users who are NOT on the Enterprise (Exchange) server

[Field 6]
Type=Label
Left=30
Top=111
Right=235
Bottom=121
Text=Choose this only if you are on the Exchange server

[Field 3]
Type=GroupBox
Left=0
Top=75
Right=300
Bottom=140

[Field 7]
Type=Label
Left=0
Top=0
Right=130
Bottom=10
Text=Please choose your installation method


...And here's the NSI code:


Auto-generated by EclipseNSIS Script Wizard
Jul 29, 2009 5:42:16 PM

Name "BlackBerry Desktop"

RequestExecutionLevel admin

General Symbol Definitions
!define VERSION 5.0.0.11
!define COMPANY RIM
!define URL http://www.blackberry.com

MUI Symbol Definitions
!define MUI_ICON BBD.ico
!define MUI_LICENSEPAGE_RADIOBUTTONS

Included files
!include Sections.nsh
!include MUI2.nsh

Reserved Files
ReserveFile "${NSISDIR}\Plugins\AdvSplash.dll"

Installer pages
!insertmacro MUI_PAGE_WELCOME
!insertmacro MUI_PAGE_LICENSE license.txt
!insertmacro MUI_PAGE_COMPONENTS
!insertmacro MUI_PAGE_INSTFILES
!insertmacro MUI_PAGE_FINISH
Installer languages
!insertmacro MUI_LANGUAGE English

Installer attributes
OutFile RIM_BlackBerry_Desktop_5.0.exe
InstallDir "$TEMP\RIM BlackBerry Desktop 5.0 Setup Files"
CRCCheck on
XPStyle on
ShowInstDetails hide
VIProductVersion 5.0.0.11
VIAddVersionKey /LANG=${LANG_ENGLISH} ProductName "BlackBerry Desktop"
VIAddVersionKey /LANG=${LANG_ENGLISH} ProductVersion "${VERSION}"
VIAddVersionKey /LANG=${LANG_ENGLISH} CompanyName "${COMPANY}"
VIAddVersionKey /LANG=${LANG_ENGLISH} CompanyWebsite "${URL}"
VIAddVersionKey /LANG=${LANG_ENGLISH} FileVersion "${VERSION}"
VIAddVersionKey /LANG=${LANG_ENGLISH} FileDescription ""
VIAddVersionKey /LANG=${LANG_ENGLISH} LegalCopyright ""

Installer sections
Section /o Main SEC0000
SetOutPath $INSTDIR
SetOverwrite ifdiff
; TESTING PHASE
SectionEnd

SectionGroup /e "BlackBerry Desktop Section"
Section /o Internet SEC0001
SetOutPath $INSTDIR\DRIVERS
SetOverwrite ifdiff
; Execwait 'msiexec /i "$INSTDIR\BlackBerry USB and Modem Drivers_ENG (DM5.0b28).msi" /passive'
SetOutPath $INSTDIR
SetOverwrite ifdiff
; File /r *
; ExecWait '"$INSTDIR\Setup.exe" /S/v/qb!'
SectionEnd

Section /o Enterprise SEC0002
SetOutPath $INSTDIR\DRIVERS
SetOverwrite ifdiff
; Execwait 'msiexec /i "$INSTDIR\BlackBerry USB and Modem Drivers_ENG (DM5.0b28).msi" /passive'
SetOutPath $INSTDIR
SetOverwrite ifdiff
; File /r *
; Delete /REBOOTOK "$INSTDIR\Setup.ini"
; Rename /REBOOTOK "$INSTDIR\Setup_Enterprise.ini" "$INSTDIR\Setup.ini"
; ExecWait '"$INSTDIR\Setup.exe" /S/v/qb!'
SectionEnd
SectionGroupEnd

Section Descriptions
!insertmacro MUI_FUNCTION_DESCRIPTION_BEGIN
!insertmacro MUI_DESCRIPTION_TEXT ${SEC0000} $(SEC0000_DESC)
!insertmacro MUI_DESCRIPTION_TEXT ${SEC0001} $(SEC0001_DESC)
!insertmacro MUI_FUNCTION_DESCRIPTION_END

Installer Language Strings
TODO Update the Language Strings with the appropriate translations.

LangString SEC0000_DESC ${LANG_ENGLISH} "Installation for non-Exchange/Enterprise BlackBerry Users"
LangString SEC0001_DESC ${LANG_ENGLISH} "Installation for Exchange/Enterprise BlackBerry Users"

+1  A: 

You could start by creating a global variable with Var IsEnterprise or something like that.

To get the actual page working, you would insert a page command somewhere between your existing MUI_PAGE macros

page EnterprisePageCreate EnterprisePageLeave

EnterprisePageCreate and EnterprisePageLeave should be nsis functions, the create function should create the page and the leave function should get the state from the radio buttons and save it in your global $IsEnterprise (You can find the info on how to do this in the InstallOptions readme and examples)

Then later on you could use $IsEnterprise in a section.

But since you already have a section called Enterprise, I would assume that you just want to toggle this section. If that is the case, there is no need to save the state in a var, you could toggle the sections "checkbox" with the macros in sections.nsh in the EnterprisePageLeave function.

You also mention that you want to jump to the InstFiles page, looking at the script you posted, I would just put the custom page before the components page and when Enterprise radio is on, turn on the section, otherwise, turn it off and make it read only.


On a unrelated note, just using RequestExecutionLevel admin is not enough, when UAC is off or < Vista, you need to use the UserInfo plugin to detect if the user is admin or not.

Anders
I'm also looking into nsDialogs. Quite a bit different than InstallOptions, but supposedly can use an INI.I have the functions down and working, but just need it to take the GetState variables and pass them along to the sections I have for Internet/Enterprise.
A: 

Ended up doing using nsDialogs. No GUI, but more control from a design standpoint it seems.

Got the Radio-button page to work fine, except that it shows the custom page with the 'License Agreement' Subcaption when the installer runs.

NSI Code:

Name "BlackBerry Desktop"

RequestExecutionLevel admin

General Symbol Definitions
!define VERSION 5.0.0.11
!define COMPANY RIM
!define URL http://www.blackberry.com

MUI Symbol Definitions
!define MUI_ICON Blackberry.ico
!define MUI_LICENSEPAGE_RADIOBUTTONS

Included files
!include Sections.nsh
!include MUI2.nsh
!include nsDialogs.nsh
!include LogicLib.nsh

Variables Var /GLOBAL AccountType
Var InstallerSelect
Var Label
Var Label_2
Var Label_3
Var RadioButton_1
Var RadioButton_2
Var /GLOBAL RadioButton_1_State
Var /GLOBAL RadioButton_2_State

Reserved Files
ReserveFile "${NSISDIR}\Plugins\AdvSplash.dll"

Installer pages
!insertmacro MUI_PAGE_WELCOME
!insertmacro MUI_PAGE_LICENSE license.txt
;Page Custom InstallerSelect InstallerSelectLeave
PageEx custom
PageCallbacks InstallerSelect InstallerSelectLeave
Caption " "
PageExEnd
!insertmacro MUI_PAGE_INSTFILES
!insertmacro MUI_PAGE_FINISH
Installer languages
!insertmacro MUI_LANGUAGE English

Installer attributes
OutFile "RIM_BlackBerry_Desktop_5.0.exe"
InstallDir "$TEMP\RIM BlackBerry Desktop 5.0 Setup Files"
CRCCheck on
XPStyle on
ShowInstDetails hide
VIProductVersion 5.0.0.11
VIAddVersionKey /LANG=${LANG_ENGLISH}
ProductName "BlackBerry Desktop"
VIAddVersionKey /LANG=${LANG_ENGLISH}
ProductVersion "${VERSION}"
VIAddVersionKey /LANG=${LANG_ENGLISH}
CompanyName "${COMPANY}"
VIAddVersionKey /LANG=${LANG_ENGLISH}
CompanyWebsite "${URL}"
VIAddVersionKey /LANG=${LANG_ENGLISH}
FileVersion "${VERSION}"
VIAddVersionKey /LANG=${LANG_ENGLISH}
FileDescription "" VIAddVersionKey
/LANG=${LANG_ENGLISH} LegalCopyright ""

;Check Admin Function
Function CheckAdmin
; Check if the current user has Administrator rights
userInfo::getAccountType
pop $AccountType
strCmp $AccountType "Admin" +3
messageBox MB_OK "You do not have Administrator rights.$\n$\nInstallation cancelled"
Quit
return
FunctionEnd

;Select Installation-type Page Functions
Function InstallerSelect
nsDialogs::create 1018
Pop $InstallerSelect

    ${If} $InstallerSelect == error <br>
            Abort <br>
    ${EndIf} <br>

    ${NSD_CreateLabel} 0 0 100% 12u "Please select an installation type..." <br>
    Pop $Label <br>

    ${NSD_CreateLabel} 10% 30% 90% 20 "For users who are NOT on the Enterprise (Exchange) server" <br>
    Pop $Label_2 <br>

    ${NSD_CreateLabel} 10% 70% 90% 20 "For users who are on the Enterprise (Exchange) server" <br>
    Pop $Label_3         <br>

    ${NSD_CreateRadioButton} 5% 20% 100% 20 "Internet" <br>
    Pop $RadioButton_1 <br>

    ${NSD_CreateRadioButton} 5% 60% 100% 20 "Enterprise" <br>
    Pop $RadioButton_2 <br>

    ${If} $RadioButton_1_State == ${BST_CHECKED} <br>
            ${NSD_Check} $RadioButton_1 <br>
    ${EndIf}  <br>

    ${If} $RadioButton_2_State == ${BST_CHECKED} <br>
            ${NSD_Check} $RadioButton_2 <br>
    ${EndIf} <br>

    nsDialogs::Show  <br>

FunctionEnd

Function InstallerSelectLeave
${NSD_GetState} $RadioButton_1 $RadioButton_1_State
${NSD_GetState} $RadioButton_2 $RadioButton_2_State
FunctionEnd

Installer sections

Section -Main SEC0000
Call CheckAdmin

SetOutPath $INSTDIR\BB_MS
SetOverwrite ifdiff
File /r BB_MS\*
SetOutPath $INSTDIR\Drivers
SetOverwrite ifdiff
File /r DRIVERS\*
SetOutPath $INSTDIR\ISSetupPrerequisites
SetOverwrite ifdiff
File /r ISSetupPrerequisites\*
SetOutPath $INSTDIR
SetOverwrite ifdiff
File "_setup.exe"
File "0x0409.ini"
File "Autorun.inf"
File "BBDMUtil.dll"
File "BlackBerry Desktop Software.msi"
File "BlackBerrySetup.exe"
File "Data1.cab"
File "FLEXnet_patch_Q113020.exe"
File "install.txt"
File "install_ENT_silent.cmd"
File "install_ENT_ui.cmd"
File "install_INT_silent.cmd"
File "install_INT_ui.cmd"
File "setup.bmp"
File "Setup_Internet.ini"
File "Setup_Enterprise.ini"
File "WindowsInstaller-KB893803-x86.exe"

; Checks selected installation method
StrCmp $RadioButton_1_State 1 Internet 0
StrCmp $RadioButton_2_State 1 Enterprise Internet

 Internet: <br>
Execwait 'msiexec /i "$INSTDIR\Drivers\BlackBerry USB and Modem Drivers_ENG (DM5.0b28).msi" /passive /norestart' <br>
Rename "$INSTDIR\Setup_Internet.ini" "$INSTDIR\Setup.ini" <br>
Sleep 1000 <br>
ExecWait '"$INSTDIR\BlackBerrySetup.exe" /S /v/passive' <br>
    Goto End <br>

Enterprise:
Execwait 'msiexec /i "$INSTDIR\Drivers\BlackBerry USB and Modem Drivers_ENG (DM5.0b28).msi" /passive /norestart'
Rename "$INSTDIR\Setup_Enterprise.ini" "$INSTDIR\Setup.ini"
Sleep 1000
ExecWait '"$INSTDIR\BlackBerrySetup.exe" /S /v/passive'

END:
SectionEnd

Installer functions
Function .onInit
InitPluginsDir
Push $R1
File /oname=$PLUGINSDIR\spltmp.bmp Blackberry.bmp
advsplash::show 1000 600 400 0x666666 $PLUGINSDIR\spltmp
Pop $R1
Pop $R1 FunctionEnd