문제

As a new NSIS user, I have defaulted to the HM NIS Edit wizard to create my installers so far. The default output takes advantage of MUI, which has been very useful to me. It also, however, includes a components page from the MUI macro library, so I cannot pick and choose which components are mandatory. I have looked at this question: How to make a SectionGroup mandatory in NSIS script, but I'm not sure where to put it in my code below, or even how to modify the wizard's output code to include it. The installer is for several apps with distinct (selectable) executables that all require the same (ideally mandatory) support files.

; HM NIS Edit Wizard helper defines
!define PRODUCT_NAME "Product"
!define PRODUCT_VERSION "1.0"
!define PRODUCT_DIR_REGKEY "Software\Microsoft\Windows\CurrentVersion\App Paths\App1.exe"
!define PRODUCT_UNINST_KEY "Software\Microsoft\Windows\CurrentVersion\Uninstall\${PRODUCT_NAME}"
!define PRODUCT_UNINST_ROOT_KEY "HKLM"

; MUI 1.67 compatible ------
!include "MUI.nsh"

; MUI Settings
!define MUI_ABORTWARNING
!define MUI_ICON "${NSISDIR}\Contrib\Graphics\Icons\modern-install.ico"
!define MUI_UNICON "${NSISDIR}\Contrib\Graphics\Icons\modern-uninstall.ico"

; Welcome page
!insertmacro MUI_PAGE_WELCOME
; Instfiles page
!insertmacro MUI_PAGE_INSTFILES
; Finish page
!insertmacro MUI_PAGE_FINISH

; Uninstaller pages
!insertmacro MUI_UNPAGE_INSTFILES

; Language files
!insertmacro MUI_LANGUAGE "English"

; MUI end ------

Name "${PRODUCT_NAME} ${PRODUCT_VERSION}"
OutFile "Setup.exe"
InstallDir "$PROGRAMFILES\Product"
InstallDirRegKey HKLM "${PRODUCT_DIR_REGKEY}" ""
ShowInstDetails show
ShowUnInstDetails show

Section "Support Files" SEC01
  SetOutPath "$INSTDIR"
  SetOverwrite try
  File "..\Support\File\Path\file.txt"
SectionEnd

Section "App1" SEC02
  SetOutPath "$INSTDIR"
  SetOverwrite try
  File "..\App1\File\Path\App1.exe"
SectionEnd

Section "App2" SEC03
  SetOutPath "$INSTDIR"
  SetOverwrite try
  File "..\App2\File\Path\App2.exe"
SectionEnd

In short, I need to know how to make the Support Files section mandatory, without losing the GUI. My only experience, though, is with the above-mentioned wizard.

도움이 되었습니까?

해결책

The SectionIn instruction is used to assign sections to install types (Combobox on the components page) but it can also make sections read-only:

Section "Support Files" SEC01
  SectionIn RO ;Make it read-only
  SetOutPath "$INSTDIR"
  SetOverwrite try
  File "..\Support\File\Path\file.txt"
SectionEnd
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top