Archive: How to get Current Working Directory


How to get Current Working Directory
Hi,

I was wondering how to get the current working directory from within a NSIS installer.

I know about the GetExePath function and $EXEDir variable, but they only refer to the location of the NSIS installer. If the NSIS installer is not in the current working directory this won't work.

Anyone?


$OUTDIR should be what you're looking for.


Originally posted by Comperio
$OUTDIR should be what you're looking for.
Not exactly. What I need is a way to determine from which directory the installer is started. For example: the installer myinstaller.exe is located in c:\temp.

Someone startes myinstaller.exe from d:\data by typing c:\temp\myinstaller.exe. What I need is a var that contains 'd:\data'. $OUTDIR contains c:\temp, $EXEDir contains c:\temp and GetExePath also contains c:\temp.

Maybe a call to the function GetCurrentDirectoryA from kernel32 will work, but I cannot seem to figure out how to set this up..

Name "Output"
OutFile "Output.exe"

Section
System::Call "kernel32::GetCurrentDirectory(i ${NSIS_MAX_STRLEN}, t .r0)"
MessageBox MB_OK "$0"
SectionEnd

Originally posted by Instructor
Name "Output"
OutFile "Output.exe"

Section
System::Call "kernel32::GetCurrentDirectory(i ${NSIS_MAX_STRLEN}, t .r0)"
MessageBox MB_OK "$0"
SectionEnd
That's it! Thanks! :)