Winamp & Shoutcast Forums

Winamp & Shoutcast Forums (http://forums.winamp.com/index.php)
-   NSIS Discussion (http://forums.winamp.com/forumdisplay.php?f=65)
-   -   how to insert operation in every files installed? (http://forums.winamp.com/showthread.php?t=337189)

xinjiang 8th November 2011 07:10

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?

MSG 8th November 2011 12:24

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

xinjiang 14th November 2011 05:03

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?

MSG 14th November 2011 08:24

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.

Zinthose 14th November 2011 14:04

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.

xinjiang 9th December 2011 06:25

I see. thank you all.


All times are GMT. The time now is 17:24.

Copyright © 1999 - 2010 Nullsoft. All Rights Reserved.