Archive: 2.0b1 $EXEDIR bug


2.0b1 $EXEDIR bug
  In both 2.0b1 and in the nighlty downloaded a few minutes ago from http://nsis.sourceforge.net/nightly/nsis.zip $EXEDIR is not set correctly if the location is the root directory.

If you run an exe from 'C:\' the $EXEDIR is set to 'C' instead of 'C:' as it was in 20b0

Currently I have a workaround which is as follows


!define EXEDR $8 ; Spare Global contains Fixed EXEDIR variable
StrLen ${TEMP1} $EXEDIR
strcpy ${EXEDR} $EXEDIR
IntCmp ${TEMP1} 1 +2 +1 exedirOK
strcpy ${EXEDR} "C"
strcpy ${EXEDR} "${EXEDR}:"
MessageBox MB_OK "$EXEDIR = ${TEMP1} ${EXEDR}"
exedirOK:

The work around is paranoid and sets the new global to C: if $EXEDIR is not defined at all. I have stuck this code in my .onInit function

Share & Enjoy

DD
PS the Help About Dialog for the betas still says version 1.9 which is a bit misleading

This code should provide a better workaround as you don't have to spare a variable for it:


onInit

StrLen$0 $EXEDIR
StrCmp$0 1 0 +2
StrCpy $EXEDIR "$EXEDIR:\"
FunctionEnd
>
Here is the bug report:

http://sourceforge.net/tracker/index...49&atid=373085

The about dialog you are talking about is for MakeNSISw, not NSIS. On the bottom of that dialog you can find the version of NSIS too.


StrCpy $EXEDIR "$EXEDIR:\"

Two problems with that idea
1) you really don't want the \ as $EXEDIR doesn't have a trailing \ in other circs
2) it doesn't work, it seems not to be possible to set $EXEDIR - at least not in the nightly I'm using

1) It works. The installer doesn't use $EXEDIR after .onInit, it's only for your use and NSIS automatically trims down the trailing back-slash when you use it.
2) What error do you get? It worked perfectly fine for me. I am also using the latest version, and I haven't changed anythign relating to this since the latest nightly.


I have fixed this bug in the latest CVS version. Please try it and tell me if it works for you.


It works! Thanks much.

FYI Below is a suitable test case if you need one. You will see that you get an error trying to create the license.txt file with older versions of makensisw but that it works in the CVS build


; test.nsi
;

; The name of the installer (not really used in a silent install)
Name "test"

; Set to silent mode
SilentInstall silent

; The file to write
OutFile "test.exe"

Function .onInit
MessageBox MB_OK "Exedir is '$EXEDIR'"
StrCpy $EXEDIR "C:\"

FunctionEnd

; The stuff to install
Section ""
; Set output path to the $EXEDIR directory.
MessageBox MB_OK "Exedir is now '$EXEDIR'"
SetOutPath $EXEDIR
; Extract file
File "..\license.txt"
; View file

SectionEnd


I think you meant makensis.exe rather than makensisw.exe. I'm getting a bit sick of people confusing the two, I wonder what we could/should do about this, if anything?