Old 8th November 2011, 07:10   #1
xinjiang
Junior Member
 
Join Date: Jul 2011
Posts: 3
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?
xinjiang is offline   Reply With Quote
Old 8th November 2011, 12:24   #2
MSG
Major Dude
 
Join Date: Oct 2006
Posts: 1,892
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
MSG is offline   Reply With Quote
Old 14th November 2011, 05:03   #3
xinjiang
Junior Member
 
Join Date: Jul 2011
Posts: 3
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?
xinjiang is offline   Reply With Quote
Old 14th November 2011, 08:24   #4
MSG
Major Dude
 
Join Date: Oct 2006
Posts: 1,892
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.
MSG is offline   Reply With Quote
Old 14th November 2011, 14:04   #5
Zinthose
Senior Member
 
Join Date: May 2009
Posts: 152
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.
Zinthose is offline   Reply With Quote
Old 9th December 2011, 06:25   #6
xinjiang
Junior Member
 
Join Date: Jul 2011
Posts: 3
I see. thank you all.
xinjiang is offline   Reply With Quote
Reply
Go Back   Winamp & Shoutcast Forums > Developer Center > NSIS Discussion

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump