Archive: Select files to install from a list


Select files to install from a list
Hello all,

I want to have an installer with files loaded in
so that I would have a list (with checkboxes) and I can check what I want to install and what not...

so far I created a listbox with the Embeddedlists plugin
and it works fine ..

my problem is .. how do I load the files to be inside
the installer and dynamicly tell the installer what to copy(install) and what not according to my list


I hope my problem is clear
thanx
Eli


To include files in your installer, you can use either "ReserveFile <file>" at the top of your script, or "File <filespec>" in a section or Function - even if you never end up using that section or Function. E.g. a hidden unselected section, or just never call that function.

As for when to install files or not, check the examples for EmbeddedLists. I found the following bit in ListView_CheckBoxes.nsi:


Function ListViewLeave
StrCpy $R1 `` ; Clear checked items list.
Pop $R0 ; Checked item text.
StrCmp $R0 /END +3 ; No item checked?
StrCpy $R1 $R1|$R0
Goto -3 ; Loop.
; etc.



All this does is create a string with each checked item's name delimited by a "|" character. You can easily retool this to install files, or not:


Function ListViewLeave
StrCpy $R1 `` ; Clear checked items list.
_loop:
Pop $R0 ; Checked item text.
StrCmp $R0 /END _end ; No item checked?
StrCmp $R0 "filename.ext" 0 +3
SetOutPath "c:\some\path\"
File "filespec"
StrCmp $R0 "anotherfilename.ext" 0 +3
SetOutPath "c:\some\other\path\"
File "filespec"
; etc.
Goto _loop ; Loop.
_end:


Note that this would start installing files as soon as you leave the ListView page. If you want this done later, then you should retool the original code to put the "|"-delimited in a variable that you'll access from a later page. You can then use the StrCpy and StrCmp commands to go over that list and do much the same as in the adjusted example above.

Do I HAVE to specify every file I want to work with ?
can't I pass File a parameter ?

Its just that the files are dynamicly changing
(thers a script that creates th ini file automaticly)


Using the File instruction puts the file into your installer executable. If you just want to copy the file from one place to another, use CopyFiles.

-Stu


can CopyFile copy from inside the installer ??

How do I direct it ?


As I've already explained, File puts the file into your installer and extracts it to $OUTDIR.
Use the SetOutPath instruction to set the current output folder.

-Stu


ok .. but this is the thing
I need to extract only files that have been selected in the list.
and the file list is dynamic, so I need to put parameter
in File, but I can't

is there something else that I can do ?


What I eventualy did is
to extract akk the files to a directory in $TEMP
copy what I need and then delete that directory ..

if there is a smarter way .. pls share :)


You can jump over the File instructions if they aren't in your list. It might be easiest to store your file names in an array using the NSISArray plugin.

-Stu


how do I load the files to be inside the installer according to my list, so that I don't have to change my script every time when the files to be installed changed.


I'm confused now. Surely your list needs to be read at run time? You can't modify which files are in the installer at run time, because the files are placed in the installer at compile time!
All you can do, is include all the files inside the installer, and extract only those required.

-Stu