Skip to content
⌘ NSIS Forum Archive

Dynamically rename a uninstall section

4 posts

bambou51#edited

Dynamically rename a uninstall section

How can I rename an uninstall section ?

Here is my component structure:

SectionGroup /e "un.Websites" Ugroup1
Section "un.section1" Usection1
SectionEnd
SectionGroupEnd

...

Function un.onInit
...
SectionSetText ${Usection1} "newname"
...
Functionend

I have a warning telling me:
unknown variable/constant "{Usection1}" detected, ignoring (stdin:529)
but same thing is working fine for install component.
Afrow UK#
I'm glad you noticed the warning. A lot of people ignore it.
Anyway, just make sure sure you put your un.onInit function under the sections themselves.
If you have your un.onInit function before the install sections, then the "Usection1" has not been defined at that time.

-Stu
bambou51#
Thx a lot it was exactly my problem.
Now I just have a last problem before completing my script.
The purpose of my script, is to display dynamically uninstall sections depending on the number of websites installed by the setup.
So someone suggested that I created a large amount of hidden sections, and that I display them dynamically during un.onInit.
It is working fine, but I have a loop that recovers my website names, and renames my sections.
Is it possible to do something like this:

SectionSetText "${Usection}$IDX" "newname"

where IDX my section idx ?
Afrow UK#
Yes. ${Usection} just contains the section index, where the first Section or SectionGroup has an index of 0.
So, if you just use $IDX instead of ${Usection}$IDX, then you can loop through all your Sections.

So for your sample posted above, you should start at 1 and end at 1.

-Stu