我有一个非常简单的 NSIS 脚本,它允许用户选择他们想要安装的组件,但是如果他们没有选择任何东西,我需要一种说“请选择一个组件”的方式。
这是脚本:
# Based on the one-section example
# http://nsis.sourceforge.net/Examples/one-section.nsi
!include "sections.nsh"
Name "Humira & You"
OutFile "Humira & You - September 2012.exe"
RequestExecutionLevel user
Page components
Page instfiles
Section /o "Rheumatoid Arthritis" P1
File "/oname=$pluginsdir\Setup.msi" "setupfiles\Humira and you - Rheumatoid Arthritis.msi"
SectionEnd
Section /o "Psoriatic Arthritis" P2
File "/oname=$pluginsdir\Setup.msi" "setupfiles\Humira and you - Psoriatic Arthritis.msi"
SectionEnd
Section /o "Ankylosing Spondylitis" P3
File "/oname=$pluginsdir\Setup.msi" "setupfiles\Humira and you - Ankylosing Spondylitis.msi"
SectionEnd
Section /o "Axial Spondyloarthritis" P4
File "/oname=$pluginsdir\Setup.msi" "setupfiles\Humira and you - Axial Spondyloarthritis.msi"
SectionEnd
Section ; Hidden section that runs the show
DetailPrint "Installing selected application..."
SetDetailsPrint none
ExecWait '"msiexec" /i "$pluginsdir\Setup.msi"'
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 RadioButton ${P3}
!insertmacro RadioButton ${P4}
!insertmacro EndRadioButtons
FunctionEnd
我环顾四周,发现了这个例子,http://nsis.sourceforge.net/Useful_InstallOptions_and_MUI_macros#Macro:_CHECKBOXCHECKER,但对于我想要的来说,它似乎过于复杂。有没有办法在 NSIS 中说:
if ($1.selectedIndex > -1) {
// continue
} else {
MessageBox.Show("Please select");
}
谢谢,格雷格。