Archive: Special Option


Special Option
  Could someone help me, :rolleyes:

because i want that at the end of the (my) setup/instalation. The instalation places a copy of the instalation file in a specific folder.

I hope you guys know what i mean, because my english is very bad. :cry:

cai_sebas


You can process $CMDLINE to get the installer name and then use CopyFiles to copy it to $INSTDIR.


I just needed this on a installer I made, and here's the modification to the GetParameters function I found in the NSIS archive.

You have to call this function before copying the file, and the name of the installer is saved in the $2 variable.


GetParameters

Push $R0
Push $R1
Push $R2
StrCpy $R0 $CMDLINE 1
StrCpy $R1 '"'
StrCpy $R2 1
StrCmp $R0'"' loop
StrCpy $R1' ' ; were scanning for a space instead of a quote
loop:
StrCpy $R0 $CMDLINE 1 $R2
StrCmp $R0 $R1 loop2
StrCmp $R0"\" "" "nofile"
IntOp $2 $R2 + 1
nofile:
;MessageBox MB_OK "
r0: $R0"
StrCmp $R0 "" loop2
IntOp $R2 $R2 + 1
Goto loop
loop2:
IntOp $R0 $R2 - $2
IntOp $R0 $R0 - 4
;MessageBox MB_OK "$R2 - $2 = $R0"
StrCpy $2 $CMDLINE $R0 $2 ; we save the filename
;MessageBox MB_OK "$2"
loop2b:
IntOp $R2 $R2 + 1
StrCpy $R0 $CMDLINE 1 $R2
;MessageBox MB_OK "rr0: $R0"
StrCmp $R0 " " loop2b
StrCpy $R0 $CMDLINE "" $R2
Pop $R2
Pop $R1
Exch $R0
FunctionEnd
>

I think that function can be made smaller.


This works.

Usage:
Call GetEXEName
Pop $R0 ;full installer exe file name


Function GetEXEName
Push $R0
Push $R1
Push $R2
StrCpy $R0 $CMDLINE -2
StrLen $R2 $R0
IntOp $R2 $R2 - 1
StrCpy $R0 $R0 "" -$R2
StrCpy $R2 0
Loop:
IntOp $R2 $R2 - 1
StrCpy $R1 $R0 1 $R2
StrCmp $R1 "" Exit
StrCmp $R1 "\" 0 Loop
IntOp $R2 $R2 + 1
StrCpy $R0 $R0 "" $R2
Exit:
Pop $R2
Pop $R1
Exch $R0
FunctionEnd


-Stu

Thanx
  Thanx, it helped me a lot. ;)

And special thanx to Deliverator who wrote a tutorial for me!

Sebas


I'll add this onto the NSIS Archive.

-Stu


Originally posted by Joost Verburg
I think that function can be made smaller.
probably ;) but I needed the filename and parameters.