Skip to content
⌘ NSIS Forum Archive

NSIS2.0b1 bug with InstallDir

7 posts

Yathosho#

NSIS2.0b1 bug with InstallDir

i got a script that queries the registry for the path of some software. since i upgraded to b1, i get the following bug:

instead of displaying C:\Program Files\Software, it leaves the ":" and displays C\Program Files\Software instead.
ReadRegStr $3 HKLM \
              "Software\Microsoft\Windows\CurrentVersion\Uninstall\Winamp3" \
              "UninstallString"
StrCmp $3 "" Winamp2Check StripPath3
Winamp2Check:
ReadRegStr $2 HKLM \
              "Software\Microsoft\Windows\CurrentVersion\Uninstall\Winamp" \
              "UninstallString"
StrCmp $2 "" End StripPath2
StripPath3:
      StrCpy $INSTDIR $3
      Call StripPath
      Goto End 
please help.
dirtydingus#
This seems to be similar to the $EXEDIR bug I just reported, although the $EXEDIR bug only occurs when $EXEDIR is the root of a drive.

DD
Yathosho#
;StripPath function by Frank Nagel
Function StripPath
  Push $8
  Push $9
  StrCmp $INSTDIR "" fin
    StrCpy $8 $INSTDIR 1 0 ; get firstchar
    StrCmp $8 '"' "" getparent 
      ; if first char is ", let's remove "'s first.
      StrCpy $INSTDIR $INSTDIR "" 1
      StrCpy $8 0
      rqloop:
        StrCpy $9 $INSTDIR 1 $8
        StrCmp $9 '"' rqdone
        StrCmp $9 "" rqdone
        IntOp $8 $8 + 1
        Goto rqloop
      rqdone:
      StrCpy $INSTDIR $INSTDIR $8
    getparent:
    ; the uninstall string goes to an EXE, let's get the directory.
    StrCpy $8 -1
    gploop:
      StrCpy $9 $INSTDIR 1 $8
      StrCmp $9 "" gpexit
      StrCmp $9 "\" gpexit
      IntOp $8 $8 - 1
      Goto gploop
    gpexit:
    StrCpy $INSTDIR $INSTDIR $8
    
  fin:
  Pop $9
  Pop $8
FunctionEnd 
kichik#
This function is no longer useful. I don't know which part exactly ruins it but the first part is useless because NSIS takes care of the quotes now and the second part does nothing but copying $INSTDIR to $INSTDIR. You can safely remove that function.
kichik#
OK. What you need to do is to first parse the install directory you get from the registry first and only then copy it to $INSTDIR. The problem is that $INSTDIR is automatically corrected and therefore can neveer contain any invalid data such as what you insert into it.