Archive: Reading the $INSTDIR from a previous installation


Reading the $INSTDIR from a previous installation
This is my first time posting a question to a forum so forgive my ignorance.

I have the following code in a previously built installer, and now I want to update the installations. Is there a way to read this entry in the registry to determine where the program was installed so I can add new files to that directory?

I have read the documentation and see that there is ReadRegStr but I can’t seem to get it. Any example would be helpful.

install:
WriteRegStr HKEY_LOCAL_MACHINE "Software\Microsoft\Windows\CurrentVersion\Uninstall\myApp " "DisplayName" "my App (Remove Only)"
WriteRegStr HKEY_LOCAL_MACHINE "Software\Microsoft\Windows\CurrentVersion\Uninstall\myApp" "UninstallString" "$INSTDIR\uninstallmyApp.exe"


:confused:


Use ÍnstallDirRegkey
Hi,

You should use the command "InstallDirRegkey" for registring the path:

; Set the default installation directory to $INSTDIR
; Use this part at the beginning of your script
InstallDir $PROGRAMFILES\MySoftware

; Registry key to check for directory : searches old entry and
; sets the $instDir variable to this path if entry exists
InstallDirRegKey HKLM SOFTWARE\MySoftware "Install_Dir"

.
.

Section "Last"
; in the last section safe the $INSTDIR to your registry
WriteRegStr HKLM SOFTWARE\MySoftware "Install_Dir" "$INSTDIR"
SectionEnd

Please have also a look on "bigtest.nsi


If InstallDirRegkey was not used
What if it's already installed and the original installer did not use InstallDirRegkey, is there any (easy) way to detect where it was installed?:weird:


Re: If InstallDirRegkey was not used

Originally posted by bdoherty
What if it's already installed and the original installer did not use InstallDirRegkey, is there any (easy) way to detect where it was installed?:weird:
If you installed a uninstall key, the path is in there. NSIS is smart enough to take of the file name on the end of it. Just make sure you don't uninstall first.

sample
I think I’m missing something. Could someone help with some sample code? I can’t quit figure out how to use ReadRegStr to get the path based on the sample code above.
Help!
:confused: