2012-06-18 6 views
2

나는 NSIS 무인 옵션

공유 공유 세 가지 섹션

  • 섹션 메인
  • 섹션 마이너
  • 섹션이 보이지 설치 될 것 NSIS 스크립트를 구축하고자 Main 또는 Minor가 선택되었는지 확인하십시오. 설치 프로그램을 시작하면 모든 섹션 (Main, Minor)이 선택됩니다.

    이제 섹션을 정의 할 수 있어야합니다 (자동 설치). Main 또는 Minor 또는 Both 만 설치하려면 무엇을 변경해야합니까?

답변

3
Name "Test" 
Outfile "Test.exe" 
;RequestExecutionLevel ? 

!include "Sections.nsh" 
!include "LogicLib.nsh" 
!include "FileFunc.nsh" ;For GetOptions 

Page Components "" "" EnforceSectionDependencies 
Page InstFiles 

Section /o "Main" SID_MAIN 
DetailPrint Main 
SectionEnd 

Section /o "Minor" SID_MINOR 
DetailPrint Minor 
SectionEnd 

Section "" SID_SHARED 
DetailPrint Shared 
SectionEnd 

!macro CheckSectionSwitch sw sid 
${GetOptions} $0 '${sw}' $9 
${IfNot} ${Errors} 
    StrCpy $1 1 
    !insertmacro SelectSection ${sid} 
${EndIf} 
!macroend 

Function .onInit 
${GetParameters} $0 
StrCpy $1 0 ;Any section swithes? 
ClearErrors 
!insertmacro CheckSectionSwitch '/Main' ${SID_MAIN} 
!insertmacro CheckSectionSwitch '/Minor' ${SID_MINOR} 

${If} $1 = 0 
    ;Set defaults 
    !insertmacro SelectSection ${SID_MAIN} 
    !insertmacro SelectSection ${SID_MINOR} 
${EndIf} 

call EnforceSectionDependencies 
FunctionEnd 

Function EnforceSectionDependencies 
!insertmacro UnselectSection ${SID_SHARED} 
${If} ${SectionIsSelected} ${SID_MAIN} 
${OrIf} ${SectionIsSelected} ${SID_MINOR} 
    !insertmacro SelectSection ${SID_SHARED} 
${EndIf} 
FunctionEnd 
+0

이것은 정말 잘되었습니다. 감사. – mars3142