Archive: Wrong installation path when updating


Wrong installation path when updating
I have created a setup which correctly installs my application. The application's main executable is located in a "bin" folder below the installation directory. For example, after installation, the installation directory looks like this:

{InstallDir}\bin\myapp.exe
{InstallDir}\data\datafile.dat

So far so good.

The problem is, that when I start the setup kit again, e.g. to update my app, the installer proposes "{InstallDir}\bin" as the installation directory.

Where does it get this path from and how can I correct it?

Thanks a lot,
Martin


Did you use InstallDir, InstallDirRegKey functions in your script?


The script was generated using HM NIS Editor wizard.

All I did was to add (for example) an exe file which goes to {InstallDir}\bin and a data file which goes to {InstallDir}\data.

The installation works OK. But when I start the setup again (immediately after installation), it proposes {InstallDir}\bin as the installation directory.

I can post the script tomorrow.

Thanks


Here's the script (generated with HM NIS's wizard).


Try in Section -Post change

  WriteRegStr HKLM "${PRODUCT_DIR_REGKEY}" "" "$INSTDIR\bin\myapp.exe"

on
  WriteRegStr HKLM "${PRODUCT_DIR_REGKEY}" "" "$INSTDIR"

Thanks for your help, your solution works.

But since my application is already installed and I am now in the process of creating the setup for a newer version of the app I had to solve it differently.

What I'm doing now is to check $INSTDIR in .onInit and if it ends with "\bin", I take its parent directory instead.

In case anyone is interested, here's the code I used for that:


; call this from .onInit
Function CheckInstDir
Push $INSTDIR
Push "\bin"
Call StrStr
Pop $0
StrCmp $0 "\bin" lbl_upd lbl_inst
lbl_upd:
; app is already installed, update it
Push $INSTDIR
Call GetParent
Pop $INSTDIR
lbl_inst:
FunctionEnd


The functions StrStr and GetParent can be found in the NSIS help file (Appendix C).

What are you want to do?
Now, by default, your installer place files in "c:\program files\My application\bin", where "c:\program files\My application\"=$INSTDIR -> this path selected by user. This location ($INSTDIR) store in regestry.
However, if user select "c:\programm\myapp\bin" (this is value of $INSTDIR) path to install programm your files will be place in "c:\programm\myapp\bin\bin". So if your take parent dir location of files will be "c:\programm\myapp".