jangogo
18th June 2004 04:57 UTC
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
flizebogen
18th June 2004 10:52 UTC
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.
jangogo
18th June 2004 16:18 UTC
o...I will try it , thx a lot
jangogo
19th June 2004 10:24 UTC
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,
kichik
19th June 2004 10:41 UTC
Put the code in .onInit. Sections are executed when the installation process itself begins (with the progress bar and the details log).
deguix
19th June 2004 10:49 UTC
I think you can replace all $InstPath by the variable $INSTDIR, and after remove the InstDir instruction.
kichik
19th June 2004 10:53 UTC
That won't help. The code should be in .onInit or be replaced with InstallDirRegKey.
jangogo
19th June 2004 14:49 UTC
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!