Archive: How would I Remove an UnInstaller Section from Component list if a File Exist


How would I Remove an UnInstaller Section from Component list if a File Exist
How would I Remove an UnInstaller Component from the list
if a File Exist on the install System.

Here is a Sample bit of Code to Show me With....



;--------------------------------
;--------------------------------
; Uninstaller Pages
;--------------------------------

!insertmacro MUI_UNPAGE_COMPONENTS
!insertmacro MUI_UNPAGE_INSTFILES

or Non MUI


UninstPage components
UninstPage instfiles


;--------------------------------
;--------------------------------
; Uninstaller
;--------------------------------

Section "-Un.UninstallHiddenRequiredFiles"
Delete "$INSTDIR\Uninst.exe"
Delete "$Desktop\Uninstaller.lnk"
SectionEnd

Section "Un.Compoment1"
#MYCODE
SectionEnd

Section "Un.Compoment2"
#MYCODE
SectionEnd

Section "Un.Compoment3"
#MYCODE
SectionEnd



I have a Component Page for Installation too. So If one of the Installation Sections was left off, What I want to do is Use the IfFileExists on a file that would have been installed. how do I incorporate that so a Component doesn't make the list to try and
uninstall?

That way Only What the User Installed Shows as an Option to Uninstall.

-MichaelFlya-

You can do so in un.onInit function, by invoking SectionSetFlags and SectionSetText commands. You should declare section index for each involved section.


Thanks hooklee.

I am trying to Understand what you mean. Best I can ask is
to Show me with Code. I took my Time And Wrote this. Please
Just add to it what is needed. This is what Will Teach me
best.

You need to Create two .txt Files in the Same Directory
that you Compile it in. Name them:

Readme_01.txt
Readme_02.txt


Thanks !!

If anyone can Help that would really get this Script I am
Writing be Finished !!!!

-MichaelFlya-


Here is the Script !!!


Section "Un.UnInstall Readme 01" Section3
Delete "$INSTDIR\Readme_01.txt"
SectionEnd

Section "Un.UnInstall Readme 02" Section4
Delete "$INSTDIR\Readme_02.txt"
SectionEnd

Section "-Un.Remove_What_is_Left"
Delete "$Desktop\Uninstaller.lnk"
Delete "$INSTDIR\Uninstaller.exe"
RMDir "$INSTDIR"
SectionEnd

Function un.onInit
IfFileExists $INSTDIR\Readme_01.txt +3
SectionSetFlags ${Section3} 0
SectionSetText ${Section3} ""

IfFileExists $INSTDIR\Readme_02.txt +3
SectionSetFlags ${Section4} 0
SectionSetText ${Section4} ""
FunctionEnd

Thanks Again Hooklee, This is Helping for sure.

A few things that Happen with that Code. When I install
Readme_01.txt It wants to only Give the option to Uninstall
Readme_02.txt !!!!


Also if I choose to Install Both it Doesn't Show Either in
the Uninstaller Page.

Altho I'm Sure a Simple Switch in something will Clear both
things up...

I will Mess around with it and post Back if I Get it to
Work as I intended...

And thanks because this is Definitely Working along the
Way I wanted.... What would Coding be without Bugs along
the way Anyway ????

Thanks !!!

-MichaelFlya-


Ok Here is what Fixed it...



Function un.onInit
IfFileExists $INSTDIR\Readme_01.txt 0 +3
SectionSetFlags ${Section3} 0
SectionSetText ${Section4} ""

IfFileExists $INSTDIR\Readme_02.txt 0 +3
SectionSetFlags ${Section4} 0
SectionSetText ${Section3} ""
FunctionEnd


However I needed this for Three Components so I started
building from that Example and Ended up with a Few probs
Along the way..

I will Keep at it, And if you or anyone else can still
think of something please let me know !!!!

-MichaelFlya-

Here is an update on that Code and what I have found
it Does... Which you will see the Reasons it will
Trouble More Components along the way.


This Disables it with the 0 at the End.


SectionSetFlags ${SectionANY} 0

Also you can Still Select it if the Next line of Code is
not there.

So you can still Select it and choose to uninstall it or
not... It just shows up as not checked. kinda like the
code /o Which does the same thing. which is why I'm sure
you put The Next Line there. Thinking if it is Disabled
then Why See it so they won't be able to Select it again
Perhaps.



SectionSetText ${SectionANY} ""



Ok so If the FIle is there This will Not Uninstall
(SectionAny) nor Does it Show up as a Choice to Uninstall
on the Component page.


Function un.onInit
IfFileExists $INSTDIR\Readme.txt 0 +3
SectionSetFlags ${SectionANY} 0
SectionSetText ${SectionANY} ""
FunctionEnd



Ok so If the FIle is there This will Uninstall
(SectionAny) and Does Not Show up as a Choice as an Option
on the Component page.


Function un.onInit
IfFileExists $INSTDIR\Readme.txt 0 +3
SectionSetText ${SectionANY} ""
FunctionEnd





Anyway it Works with two Sections but Three it Can't
Hide the other two and Not Still Work Correct because
the other two have to Verify whether it's there and
Would just X each other out.

I am still Looking for a Good way to go about this....

Thanks for Any Help.... Also thanks Hooklee atleast this
works so far with just two Sections... Thats a Plus...

-MichaelFlya-

Originally posted by MichaelFlya
Thanks Again Hooklee, This is Helping for sure.

A few things that Happen with that Code. When I install
Readme_01.txt It wants to only Give the option to Uninstall
Readme_02.txt !!!!


Also if I choose to Install Both it Doesn't Show Either in
the Uninstaller Page.

Altho I'm Sure a Simple Switch in something will Clear both
things up...

I will Mess around with it and post Back if I Get it to
Work as I intended...

And thanks because this is Definitely Working along the
Way I wanted.... What would Coding be without Bugs along
the way Anyway ????

Thanks !!!

-MichaelFlya-
I have tested my code. It works very well.

You SHOULD use "IfFileExists $INSTDIR\Readme_01.txt +3", not "IfFileExists $INSTDIR\Readme_01.txt 0 +3". I am puzzled why you have problems with the fommer command but get it to work with the latter command.

"IfFileExists $INSTDIR\Readme_01.txt 0 +3" means hide and unselect the section when the file exists! It is not what you want.

Anyway it Works with two Sections but Three it Can't
Hide the other two and Not Still Work Correct because
the other two have to Verify whether it's there and
Would just X each other out.

-MichaelFlya- [/B]
I cannot understand what happended for you and what do you want :(

Hooklee .......

That Works !!!!!! You had it Right the First Time I guess.
Thanks for pointing that bit of Code out ...

Actually at this point I have no Idea How that 0 Got in
there if you didn't Originally put it there, But Yep After
I removed it .... My Installer then ran just Perfectly fine,
Just the Way I wanted it to. My Mistake Caused a Fork
in the Code .... ehh I mean Road ... :)

... Don't Worry If anything I Did Learn more with that 0
There than without it ... That is more Important than
anything ....

So I got to Words for you .............

Thank You !!!!

:up: :up: :up: :up: :up: :up: :up: :up: :up: :up:

-MichaelFlya-