Archive: how to insert operation in every files installed?


how to insert operation in every files installed?
Hi, All

I want to get the install progress for another application, so i want to insert some operation after every files installed, like:

File "file_1.txt"
;do something
File "file_2.txt"
;do something
.
.
.

The problem is there are so many files make this method looks stupid and disgusting.

I try use Findfirst, FindNext to solve it, but failed like "File" don't accept a variable. the script is like:

SetOutPath "$INSTDIR"
FindFirst $0 $1 "${SOURCEDIR}\*.*"
loop:
StrCmp $1 "" done
StrCmp $1 "." next
StrCmp $1 ".." next
File "${SOURCEDIR}\$1"
System::Call "$TEMP\InstallerHelper::NotifyMovingFile(t"${SOURCEDIR}\$1") i .r0 ?u"
next:
FindNext $0 $1
Goto loop
done:

I use "File /nonfatal "${SOURCEDIR}\$1"" failed too, it looks no files is added to setup.exe.


Does anyone know how to handle this situation?


Use a macro (or a function)

!macro _FileEx Path
File ${Path}
;do something
!macroend
!define FileEx `!insertmacro _FileEx`

Section
${FileEx} "file_1.txt"
${FileEx} "file_2.txt"
SectionEnd


thanks, does there any method like "file /r *.*" to deal with any the files? because if there are many files, it is still messy.

does "file" can use a variable?


No. File is a compile-time command, so it cannot use a variable in the path parameter.

Of course you can do File /r (see the manual!), but you won't be able to get a 'do something' command for every file.

By the way, if you think a script with lots of File commands is messy, please keep in mind that your users will never see the script. And if you *really* don't want to look at a long list of File in your code, simply put it in an .nsh file and !include that file inside your section.


I had the same problem but used a !system command to execute a VBScript that generates an nsh file dynamically and then !includes the file.

I even set up the script to prompt if the nsh file previously existed if I wanted to regenerate it.

You could easily do the same thing is bash, perl, python, Autoit or what ever language you prefer. Even an NSIS package that only generates the nsh file.


I see. thank you all.