t44
14th April 2005 16:06 UTC
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
glory_man
14th April 2005 17:11 UTC
Did you use InstallDir, InstallDirRegKey functions in your script?
tinu44
14th April 2005 22:34 UTC
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
tinu44
15th April 2005 07:58 UTC
Here's the script (generated with HM NIS's wizard).
glory_man
15th April 2005 10:58 UTC
Try in Section -Post change
WriteRegStr HKLM "${PRODUCT_DIR_REGKEY}" "" "$INSTDIR\bin\myapp.exe"
on
WriteRegStr HKLM "${PRODUCT_DIR_REGKEY}" "" "$INSTDIR"
tinu44
15th April 2005 12:37 UTC
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).
glory_man
15th April 2005 13:29 UTC
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".