Get installer filename: Difference between revisions
From NSIS Wiki
Jump to navigationJump to search
m (Adding new author and category links.) |
|||
Line 7: | Line 7: | ||
;$R0 will contain the installer filename | ;$R0 will contain the installer filename | ||
</highlight-nsis> | </highlight-nsis> | ||
== METHOD 2: GET FROM THE COMMAND LINE == | == METHOD 2: GET FROM THE COMMAND LINE == | ||
Revision as of 04:57, 8 August 2005
Author: Afrow UK (talk, contrib) |
METHOD 1: USING THE WINDOWS API (RECOMMENDED)
The Script
System::Call 'kernel32::GetModuleFileNameA(i 0, t .R0, i 1024) i r1' ;$R0 will contain the installer filename
METHOD 2: GET FROM THE COMMAND LINE
Note: If the installer is executed using the console, the command line might not contain the current folder or the .exe extension.
Usage
Call GetAppName Pop $R0 ;Installer filename
The Function
Function GetAppName Push $R0 Push $R1 Push $R2 Push $R3 StrCpy $R2 1 StrLen $R3 $CMDLINE ;Check for quote or space StrCpy $R0 $CMDLINE $R2 StrCmp $R0 '"' 0 +3 StrCpy $R1 '"' Goto loop StrCpy $R1 " " loop: IntOp $R2 $R2 + 1 StrCpy $R0 $CMDLINE 1 $R2 StrCmp $R0 $R1 get StrCmp $R2 $R3 get Goto loop get: StrCmp $R1 '"' 0 +4 IntOp $R2 $R2 - 1 StrCpy $R0 $CMDLINE $R2 1 Goto exit StrCpy $R0 $CMDLINE $R2 exit: Pop $R3 Pop $R2 Pop $R1 Exch $R0 FunctionEnd