Archive: Change the CWD/getting the '*.nsi' script directory


Change the CWD/getting the '*.nsi' script directory
When I compile an NSIS script from the command line I want it always to output the exe file in the current working directory - not the same directory as the *.nsi script.

So if my cwd was:
'C:/temp'

and I say
'C:/Program Files/NSIS/makensis.exe D:/MyInstaller.nsi'

How can I get the 'MyInstaller.exe' to be created in 'C:/temp'?

Also, if I get the cwd to be 'C:/temp' at compile time, can I still get the directory location of the *.nsi script so I can do this:
ReserveFile ${NSIFilePath}/MyPerlScript.pl

At the moment I have something like this:
ReserveFile ./MyPerlScript.pl

Which is a problem because the files I need to reserve are relative to the *.nsi script, and obviously changing the cwd would stop this from compiling. Cheers for any help on this one! ;)


hm, something like: makensis /Doutdir=%CD% yourscript.nsi

then in your script:
!ifndef outdir
!define outdir .
!endif
Outfile "${outdir}\foo.exe"


Yeah I'll be honest I thought I'd have do something like that. I was passing '/NOCD' as one of the args so the *.exe was being created in the CWD but then this was messing up other parts of my script which was using files relative to the *.nsi script location.

I wasn't sure if you used /NOCD if there was an easy way to know the directory location of the *.nsi script so I could have done something like:
ReserveFile ${NSIFilePath}/MyPerlScript.pl

If not then your solution is good enough for what I'm doing, cheers! :-)


well, its ugly, but ReserveFile "${__FILE__}\..\MyPerlScript.pl" might work