Archive: Exec in loop


Exec in loop
Hi,

I'm trying to wrap a suit of installers. Since there may be many changes in the suit, it needs to be customizable by non-programmers.
Thus, my plan is to read a list of file names from a file and execute them, but only the last one gets executed. I tried Exec and nsExec::Exec, same result.

Here is the relevant part of the script:


Section Main
FileOpen $0 "installers.lst" r
FileRead $0 $1
IfErrors end_loop
loop:
nsExec::Exec '"$1"'
Pop $2
MessageBox MB_OK "$1 returned $2"
ClearErrors
FileRead $0 $1
IfErrors 0 loop
end_loop:
FileClose $0
SectionEnd


The message box pops up for every item and shows return code "error", only the last item in the file is actually executed.
Am I doing it wrong? Or is this even intended behavior?

Thanks in advance!


PS: The installer.lst looks like this:

externals.exe
test.bat
server\apache-tomcat-5.5.27.exe
util\Firefox Setup 3.6.exe

!include TextFunc.nsh
...
ClearErrors
FileOpen $0 "installers.lst" r
${DoUntil} ${Errors}
FileRead $0 $1
${TrimNewLines} $1 $1
${If} ${FileExists} $EXEDIR\$1
nsExec::Exec `"$EXEDIR\$1"`
Pop $1
${EndIf}
${Loop}
FileClose $0
Firstly FileRead reads the newline characters so you must trim them. Secondly I would always use a full path.

Stu

Works perfectly, thank you so much!

PS: I hate newlines... : )