0

In nsi script with MUI2.nsh

Code:-

!macro SECTION_BEGIN

Section ""

Call zip2exe.SetOutPath

!macroend

!macro SECTION_END

SectionEnd

!macroend

But If I want to define two or more section then in that case how to incorporate SECTION_BEGIN part?

Section "Main Component" MainCom
  #SectionIn RO # Just means if in component mode this is locked

    Call zip2exe.SetOutPath

  ;Store installation folder in registry
  WriteRegStr HKLM "Software\${ZIP2EXE_NAME}" "" $INSTDIR

  ;Registry information for add/remove programs
  WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\${ZIP2EXE_NAME}" "DisplayName" "${ZIP2EXE_NAME}"

  WriteRegDWORD HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\${ZIP2EXE_NAME}" "NoRepair" 1

  ;Create optional start menu shortcut for uninstaller and Main component


  ;Create uninstaller
  WriteUninstaller "${ZIP2EXE_NAME}_uninstaller.exe"
#!macroend

#!macro SECTION_END

SectionEnd

#!macroend


;--------------------------------
;Uninstaller Section

Section "Uninstall"

  ;Delete the appdata directory + files
  RMDir /r "${INSTDIR_DATA}\*.*"
  RMDir "${INSTDIR_DATA}"

  ;Delete Start Menu Shortcuts
  Delete "$SMPROGRAMS\${ZIP2EXE_NAME}\*.*"
  RmDir  "$SMPROGRAMS\${ZIP2EXE_NAME}"

SectionEnd
#!macro SECTION_END

If we omit SECTION_BEGIN part then error comes. If we mention SECTION_BEGIN in both sections then also error comes. What will be the solution to this problem?

John Bollinger
  • 160,171
  • 8
  • 81
  • 157
Ankesh kumar Jaisansaria
  • 1,563
  • 4
  • 26
  • 44

1 Answers1

1

If actually want to use Zip2Exe then you can modify parts of NSIS\Contrib\zip2exe\Base.nsh from

!macro SECTION_END

  SectionEnd

!macroend

to something like this

!macro SECTION_END

  SectionEnd

  !if /FileExists "c:\mycustomzip2exefiles\mycustomsections.nsh"
  !include "c:\mycustomzip2exefiles\mycustomsections.nsh"
  !endif

!macroend

You can then put whatever code you want in c:\mycustomzip2exefiles\mycustomsections.nsh:

Section "My other section"
SetOutPath $InstDir
File "anotherfile.txt"
SectionEnd

However, Zip2Exe is mainly something you use to create simple self-extracting executables, you should not use it to create full installers.

When you create a real installer you don't use Zip2Exe, you use MakeNSIS and there is no such thing as a SECTION_BEGIN macro, you just add as many sections as you want to your .NSI file.

Example2.nsi contains a basic installer/uninstaller.

Anders
  • 97,548
  • 12
  • 110
  • 164