Get installer filename: Difference between revisions
From NSIS Wiki
Jump to navigationJump to search
m (Wikipedia python library) |
m (Updated author and download links, and changed format of some pages.) |
||
Line 58: | Line 58: | ||
</highlight-nsis> | </highlight-nsis> | ||
Page author: Afrow UK | Page author: [[User:Afrow UK|Afrow UK]] |
Revision as of 12:39, 23 April 2005
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
Page author: Afrow UK