gfyans
gfyans

Reputation: 1256

NSIS - Radio button to select one of many programs to install

I have 4 programs that I'd like to package into one installer and allow the user to select which one they would like to install.

I've never used NSIS before but I was recommended to give it a shot, however, I've no idea where to begin with this.

Basically I just need one page that asks the user to select a radio button then click next to install one of the following programs:

-- Install components --------------------

Select a program from the list below and
click Next to continue.

O Program 1
O Program 2
O Program 3
O Program 4


-------------------------------------------

Cancel                                 Next

Then depending on what they choose it launches program1_setup.exe or program2_setup.exe etc.

As each of my 4 programs are installers in their own right, I take it I don't need to set up the uninstall script in NSIS as that's taken care of already?

Thanks, Greg.

Upvotes: 3

Views: 5759

Answers (1)

Anders
Anders

Reputation: 101666

This code is similar to the one-section.nsi example.

...

!include sections.nsh

Page components
Page instfiles

Section /o "Program 1" P1
File "/oname=$pluginsdir\Setup.exe" "myfiles\Setup1.exe"
SectionEnd

Section "Program 2" P2
File "/oname=$pluginsdir\Setup.exe" "myfiles\Setup2.exe"
SectionEnd

Section ; Hidden section that runs the show
DetailPrint "Installing selected application..."
SetDetailsPrint none
ExecWait '"$pluginsdir\Setup.exe"'
SetDetailsPrint lastused
SectionEnd

Function .onInit
Initpluginsdir ; Make sure $pluginsdir exists
StrCpy $1 ${P2} ;The default
FunctionEnd

Function .onSelChange
!insertmacro StartRadioButtons $1
    !insertmacro RadioButton ${P1}
    !insertmacro RadioButton ${P2}
!insertmacro EndRadioButtons
FunctionEnd

You can use the CheckBitmap attribute to change the checkbox icons if you want...

Upvotes: 4

Related Questions