CombinedUnInstaller

From NSIS Wiki
Jump to navigationJump to search
Author: Jan (talk, contrib)


Description

The Combined UnInstaller (CUIN) combines both, installer and uninstaller, in one executable with a shared components page. Depending on the users preferences, different sections will be displayed.

Script Code

;combined unInstaller by jan t. sott
!include "Sections.nsh"
 
Name "combined unInstaller 0.1"
OutFile "cuin.exe"
AutoCloseWindow true
 
Page Components
Page InstFiles
 
;sections
SubSection /e "Installer" ssInst
  Section "Installer" mbInst
    MessageBox MB_OK "Successfully installed."
  SectionEnd
SubSectionEnd
 
SubSection /e "Uninstaller" ssUninst
  Section "Uninstaller" mbUninst
    MessageBox MB_OK "Successfully uninstalled."
  SectionEnd
SubSectionEnd
 
;functions
Function .onInit
  MessageBox MB_YESNO|MB_ICONEXCLAMATION \
             "YES to install. NO to uninstall." IDNO +3
    Call usUnSections
    Goto +2
  Call usSections
FunctionEnd
 
Function usSections
  SectionSetText ${ssUninst} "MessageBox"
  !insertmacro UnSelectSection "${ssInst}"
  SectionSetText ${ssInst} ""
  !insertmacro UnSelectSection "${mbInst}"
  SectionSetText ${mbInst} ""
FunctionEnd
 
Function usUnSections
  SectionSetText ${ssInst} "MessageBox"
  !insertmacro UnSelectSection "${ssUninst}"
  SectionSetText ${ssUninst} ""
  !insertmacro UnSelectSection "${mbUninst}"
  SectionSetText ${mbunInst} ""
FunctionEnd
;eof

Examples

This script was used in xpy