ritesh
2nd December 2003 11:15 UTC
Last installation directory..
Hello
By nsis script allows my app to be installed in \program files\etc.....
if a user has installed in some differnt directory and has an upgraded version of my software. how can i know where is the last installation so that by default i can show him the old directory?
need to add anything in the script...
Ritesh
kichik
2nd December 2003 12:11 UTC
You simply write $INSTDIR to the registry and use InstallDirRegKey so the next installation will be able to read it. See Examples\example2.nsi for an example. All of the MUI examples in Examples\Modern UI example this too.
treehousetim
2nd December 2003 19:35 UTC
Here is a quick macro I use for this...
it requires two entries in the .onInit and .onInstSuccess functions...
!Macro InstallLocationReg Root SubKey Key Default
Push $9
ReadRegStr $9 ${Root} ${SubKey} ${Key}
StrCmp $9 "" 0 +3
StrCpy $INSTDIR ${Default}
Goto +2
StrCpy $INSTDIR $9
Pop $9
!MacroEnd
Function .onInit
!insertmacro InstallLocationReg HKCU "SOFTWARE\Company\My\Software" "InstallDir" "$PROGRAMFILES\My\Software"
FunctionEnd
Function .onInstSuccess
WriteRegStr HKCU "SOFTWARE\Company\My\Software" "InstallDir" $INSTDIR
FunctionEnd
You also don't need to put an InstallDir "install/dir" in your script anywhere.
-Tim
kichik
2nd December 2003 19:58 UTC
Why use that macro when you have InstallDirRegKey?
treehousetim
2nd December 2003 20:09 UTC
hmm.... i don't remember, but I'm pretty sure I had a good reason!
lol
:)