Archive: Using NSIS as a app patch installer


Using NSIS as a app patch installer
NSIS is pretty good for my app installation.
and then After I upgrade some part of my app, I must have a patch install.
I have a problem when I was writing the NSIS script, That's:
I write a REG string when my app is installed
WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\${NAME}" "UninstallString" "$INSTDIR\uninstall.exe"
then I wanna to Get the REG string and get the $INSTDIR(It's the only way tells where is my app installed),so I can use this install-path to patch some of my file in my new-version-install or patch-install.
but how to write a nsis script? can anyone help me to give me a sample of that? thx alot


In the Manual in Appendix B "Useful Functions" you find the Function Getparent. Give the UninstallExename as Input String to the Function and you get the Installation Directory as result.


o...I will try it , thx a lot


why?
!define AppName "myappname"
!define AppDir "$PROGRAMFILES\myapp"

Var InstPath

Name "${AppName} Patch"

; The file to write
OutFile "VAddSP.exe"

Section "PreInst"
ReadRegStr $0 HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\${AppName}" "UninstallString"
DetailPrint $0
StrCmp "$0" "" SetOldPath SetNewPath

SetNewPath:
Push $0
Call GetParent
Pop $R0
;DetailPrint $R0 ;It's the Right path!!
StrCpy $InstPath $R0
SetOldPath:
StrCpy $InstPath ${AppDir}
SectionEnd


InstallDir $InstPath ;I got a empty string,Why?!pls,


Put the code in .onInit. Sections are executed when the installation process itself begins (with the progress bar and the details log).


I think you can replace all $InstPath by the variable $INSTDIR, and after remove the InstDir instruction.


That won't help. The code should be in .onInit or be replaced with InstallDirRegKey.


It works!

; The file to write
OutFile "VAddSP.exe"

InstallDir "${AppDir}"

; Pages
Page directory
Page instfiles

InstallDirRegKey HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\${AppName}" "UninstallString"

; kichik,Thx!