Old 4th May 2005, 10:05   #1
SnipeGod
Junior Member
 
Join Date: May 2005
Posts: 6
Self copy install ?

Is there a way to make the install file copy itself after installation into the install dir ?
SnipeGod is offline   Reply With Quote
Old 4th May 2005, 10:16   #2
glory_man
Senior Member
 
Join Date: Sep 2004
Location: Mogilev (Belarus)
Posts: 372
code:

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

glory_man is offline   Reply With Quote
Old 4th May 2005, 13:07   #3
SnipeGod
Junior Member
 
Join Date: May 2005
Posts: 6
but what if the user renamed the file ?
SnipeGod is offline   Reply With Quote
Old 4th May 2005, 13:16   #4
glory_man
Senior Member
 
Join Date: Sep 2004
Location: Mogilev (Belarus)
Posts: 372
System plugin can help you to detect filename
code:

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.
glory_man is offline   Reply With Quote
Old 4th May 2005, 14:59   #5
SnipeGod
Junior Member
 
Join Date: May 2005
Posts: 6
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
SnipeGod is offline   Reply With Quote
Old 4th May 2005, 15:25   #6
glory_man
Senior Member
 
Join Date: Sep 2004
Location: Mogilev (Belarus)
Posts: 372
I think this may be like this:
code:

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.
glory_man is offline   Reply With Quote
Old 4th May 2005, 18:17   #7
SnipeGod
Junior Member
 
Join Date: May 2005
Posts: 6
You R AMAZING!!! I O U a HUGE beer Once again THANK YOU
SnipeGod is offline   Reply With Quote
Old 4th May 2005, 18:56   #8
Afrow UK
Moderator
 
Afrow UK's Avatar
 
Join Date: Nov 2002
Location: Surrey, England
Posts: 8,434
Rather than use GetParent to get the file name (for some reason) just use GetFileName:
http://nsis.sourceforge.net/archive/...ances=0,11,211

code:
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
Afrow UK is offline   Reply With Quote
Old 4th May 2005, 19:14   #9
SnipeGod
Junior Member
 
Join Date: May 2005
Posts: 6
hmmm... OK :] I'll try it then...
SnipeGod is offline   Reply With Quote
Old 5th May 2005, 16:47   #10
kichik
M.I.A.
[NSIS Dev, Mod]
 
kichik's Avatar
 
Join Date: Oct 2001
Location: Israel
Posts: 11,343
Why use GetParent or GetFileName? CopyFiles works with full paths, it's even required:
Quote:
Fully-qualified path names should always be used with this instruction. Using relative paths will have unpredictable results.

NSIS FAQ | NSIS Home Page | Donate $
"I hear and I forget. I see and I remember. I do and I understand." -- Confucius
kichik is offline   Reply With Quote
Old 5th May 2005, 17:26   #11
Afrow UK
Moderator
 
Afrow UK's Avatar
 
Join Date: Nov 2002
Location: Surrey, England
Posts: 8,434
He needed the installer file to be copied to $INSTDIR.
GetFileName was used to get the installer file name from $R0.

-Stu
Afrow UK is offline   Reply With Quote
Old 5th May 2005, 17:31   #12
kichik
M.I.A.
[NSIS Dev, Mod]
 
kichik's Avatar
 
Join Date: Oct 2001
Location: Israel
Posts: 11,343
Right... Sorry, my bad.

NSIS FAQ | NSIS Home Page | Donate $
"I hear and I forget. I see and I remember. I do and I understand." -- Confucius
kichik is offline   Reply With Quote
Old 5th May 2005, 19:20   #13
SnipeGod
Junior Member
 
Join Date: May 2005
Posts: 6
the script works great ! nothing more to add :] thank you all for your help !!!
SnipeGod 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