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
Last installation directory..
5 posts
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.
Here is a quick macro I use for this...
it requires two entries in the .onInit and .onInstSuccess functions...
-Tim
it requires two entries in the .onInit and .onInstSuccess functions...
You also don't need to put an InstallDir "install/dir" in your script anywhere.
!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
-Tim
Why use that macro when you have InstallDirRegKey?
hmm.... i don't remember, but I'm pretty sure I had a good reason!
lol
🙂
lol
🙂