Skip to content
⌘ NSIS Forum Archive

nsis script for selecting packages for uninstallation.

4 posts

cgoma#

nsis script for selecting packages for uninstallation.

Hi,

I have created nsis script for installation of some packages on windows. This installer works fine. Currently this installer uninstall all packages and then install the packages which can be selected ( using the checkbox during installation).
I should get option given by below code during uninstallation (This is my instllation code)


Name example
OutFile example.exe

UninstPage uninstConfirm


;WriteUninstaller "$INSTDIR\uninst.exe"

ComponentText "Please choose the packages which needs to install!!!" "Install Type" "Hope it works"

Section "UI" sec1
WriteUninstaller "$INSTDIR\uninst.exe"
MessageBox MB_ICONEXCLAMATION|MB_OK ${sec1}
SectionEnd

Section "OC" sec2
MessageBox MB_ICONEXCLAMATION|MB_OK ${sec2}
SectionEnd

Section "MAX" sec3
MessageBox MB_ICONEXCLAMATION|MB_OK ${sec3}
SectionEnd

Section "DATABASE" sec4
MessageBox MB_ICONEXCLAMATION|MB_OK ${sec4}
SectionEnd

# defines for newer versions
!include Sections.nsh
# SECTION_OFF is defined in Sections.nsh as 0xFFFFFFFE
!define SECTION_ON ${SF_SELECTED} # 0x1

# defines for 2.0b0 and below
#!define SECTION_ON 0x80000000
#!define SECTION_OFF 0x7FFFFFFF

Function .onInit
Push $0

StrCpy $1 ${sec1} ; Gotta remember which section we are at now...
SectionGetFlags ${sec1} $0
IntOp $0 $0 | ${SECTION_ON}
SectionSetFlags ${sec1} $0

SectionGetFlags ${sec2} $0
IntOp $0 $0 & ${SECTION_ON}
SectionSetFlags ${sec2} $0

SectionGetFlags ${sec3} $0
IntOp $0 $0 & ${SECTION_ON}
SectionSetFlags ${sec3} $0

SectionGetFlags ${sec4} $0
IntOp $0 $0 & ${SECTION_ON}
SectionSetFlags ${sec4} $0

Pop $0
FunctionEnd
But now I wanted to uninstall only selected packages (i.e. selected using checkbox)




Please let me know what I can do to achieve this.
Anders#
It is not clear to me what you are asking but state from the installer is not automatically restored in the uninstaller. You must save state in the registry or a .ini file.
cgoma#
Hi Anders,

Thank for your reply. The code I have pasted earlier was for my installer. But now I wanted to the installer first should ask for what you need to uninstall (e.g. suppose my installer is updating a service only, then it should uninstall old service first then it should install new service.)

Please check the screenshot attached. The page in screenshot should come first while running the installer.
Anders#
Does it make sense to present a list to the user? What happens if the user chooses not to uninstall something, do you just install the new version on top or do you not install the item?