2013-08-21 33 views
0

作为新的NSIS用户,我默认使用HM NIS Edit向导创建我的安装程序。默认输出利用了MUI,这对我来说非常有用。但是,它也包含来自MUI宏库的组件页面,所以我无法选择和选择哪些组件是必需的。我已经看过这个问题:How to make a SectionGroup mandatory in NSIS script,但我不确定将它放在下面的代码中,甚至不知道如何修改向导的输出代码以包含它。安装程序适用于具有不同(可选)可执行文件的多个应用程序,这些应用程序都需要相同的(理想情况下必需的)支持文件。要求使用MUI安装组件

; 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 

总之,我需要知道如何让Support Files部分强制性,又不失GUI。但我唯一的经验就是上述的巫师。

回答

2

SectionIn指令用于分配的部分安装类型(组合框组件页),但它也可以使部分只读:

Section "Support Files" SEC01 
    SectionIn RO ;Make it read-only 
    SetOutPath "$INSTDIR" 
    SetOverwrite try 
    File "..\Support\File\Path\file.txt" 
SectionEnd