Skip to content
⌘ NSIS Forum Archive

About uninstaller

2 posts

yzldni#

About uninstaller

hello ,

my problem is:

how can i create two or three uninstaller in a installer,,

beause i have some module ex: module1, module2 ....

and i want to module1 have an uninstaller,, module2 have an uninstaller too..

my code:
Section "un.module1"

Section

Section "un.module2"

Section

i want to have two uninstaller is uninstall1 and uninstall2 ,,when i click uninstall1, it will uninstall module1,,when i click uninstall2,,,it will uninstall module2
Anders#
NSIS was not really designed to support this scenario, you might want to consider creating a full installer/uninstaller for each module.

If you really must do this:

InstallDir $temp\Test
Page Components
Page Directory
Page InstFiles
UninstPage Components
UninstPage InstFiles

!include Sections.nsh
Function un.onInit
FileOpen $0 "$EXEPATH" r
FileSeek $0 -1 END
FileReadByte $0 $1
FileClose $0
!insertmacro SelectSection $1
FunctionEnd
!macro WriteOneSectionUninstaller sid path
WriteUninstaller "${path}"
FileOpen $0 "${path}" a
FileSeek $0 0 END
FileWriteByte $0 ${sid}
FileClose $0
!macroend

Section /o "un.Product A" SID_UNA
Delete "$InstDir\A.exe"
Delete "$InstDir\UninstA.exe"
RMDIr "$InstDir"
SectionEnd

Section /o "un.Product B" SID_UNB
Delete "$InstDir\B.exe"
Delete "$InstDir\UninstB.exe"
RMDIr "$InstDir"
SectionEnd

Section "Product A"
SetOutPath "$InstDir"
File "/oname=$InstDir\A.exe" "${__FILE__}"
!insertmacro WriteOneSectionUninstaller ${SID_UNA} "$InstDir\UninstA.exe"
SectionEnd

Section "Product B"
SetOutPath "$InstDir"
File "/oname=$InstDir\B.exe" "${__FILE__}"
!insertmacro WriteOneSectionUninstaller ${SID_UNB} "$InstDir\UninstB.exe"
SectionEnd