nsisrmdir

NSIS set 'Space required' in uninstaller


My uninstaller shows 0 Kb for 'Space required' on the components page, because I have no File operations inside my Sections. But I'm deleting some files and directories using RMDir in my Sections, so I want to the 'Space required' to show the sum of all selected components.

I tried this by using SectionSetSize, but the 'Space required' still shows 0.

Section "un.Delete directory" deldirSection
# ...
SectionEnd

Function .onInit

    # ....

    MessageBox MB_OKCANCEL|MB_ICONEXCLAMATION \
    "${APPNAME} is already installed. $\n$\nClick OK to remove the \
    previous version or CANCEL to cancel this upgrade." \
    IDOK uninst
    Abort

    # Run the uninstaller

    uninst:

    # calculate size of data dir
    var /GLOBAL dirSize
    ${GetSize} $DIRPATH "/S=0K" $0 $1 $2
    IntFmt $dirSize "0x%08X" $0

    # add size of data dir to appropriate section
    SectionSetSize ${deldirSection} $dirSize

    ClearErrors
    ExecWait $INSTDIR\uninstall.exe ;  
    Abort

    done:

FunctionEnd  

Solution

  • Call SectionSetSize in un.onInit to modify the uninstaller, not .onInit.