Archive: Self copy install ?


Self copy install ?
Is there a way to make the install file copy itself after installation into the install dir ?



Function .onInstSuccess
CopyFiles /SILENT "$EXEDIR\Setup.exe" "$INSTDIR\Setup.exe"
FunctionEnd

but what if the user renamed the file ?


System plugin can help you to detect filename


System::Call 'kernel32::GetModuleFileNameA(i 0, t .R0, i 1024) i r1'

After this call $R0 will be equal to full path of file (i.e. path and file-name). Parse this variable.

wow!
thanks :D but I'm new to this scripting system so I'm not sure how to combine those two scripts to make it work :P


I think this may be like this:


Function .onInstSuccess
System::Call 'kernel32::GetModuleFileNameA(i 0, t .R0, i 1024) i r1'
StrLen $0 $R0
Push $R0
Call GetParent
Pop $1
StrLen $1 $1
IntOp $0 $0 - $1
IntOp $0 $0 - 1
StrCpy $R1 $R0 "" "-$0"
CopyFiles /SILENT "$R0" "$INSTDIR\$R1"
FunctionEnd


Add:
Forgotten: GetParent function you can take from NSIS-docs - Appendix C - Get parent directory.

You R AMAZING!!! :D I O U a HUGE beer :up: Once again THANK YOU :)


Rather than use GetParent to get the file name (for some reason) just use GetFileName:
http://nsis.sourceforge.net/archive/...ances=0,11,211

Function .onInstSuccess
System::Call 'kernel32::GetModuleFileNameA(i 0, t .R0, i 1024) i r1'
Push $R0
Call GetFileName
Pop $R1
CopyFiles "$R0" "$INSTDIR\$R1"
FunctionEnd


Edit: Silent may not be wise if the installer is large.

-Stu

hmmm... OK :] I'll try it then...


Why use GetParent or GetFileName? CopyFiles works with full paths, it's even required:

Fully-qualified path names should always be used with this instruction. Using relative paths will have unpredictable results.

He needed the installer file to be copied to $INSTDIR.
GetFileName was used to get the installer file name from $R0.

-Stu


Right... Sorry, my bad.


the script works great ! nothing more to add :] thank you all for your help !!!