I've spent hours researching my issue on the web and trial-and-erroring, but have been unable to get this to work. I'm not a programmer, and never have so much as written a .bat file. It's been like trying to learn quantum physics from textbook written in Chinese (I don't speak Chinese).
Anyway, I'm trying to check for an existing installation of my "program" (video game mod), so I can abort the install if it's already present (regardless of version). I've tried a couple variations of the function below, but I can't get it to work. I keep getting an error on the "ReadRegStr" line, but according to my installer (partially generated in HM NIS Edit), what I've defined here is what it's supposed to be written to the registry. I've also read there can be an issue with 64-bit Windows, but have no idea if that is related to my issue.
;Check for Previous Installation of ProgramTaking into consideration the following parameters that HM NIS Edit Wizard generated for me:
Function .onInit
ClearErrors
ReadRegStr ${PRODUCT_UNINST_ROOT_KEY} "${PRODUCT_UNINST_KEY}" "DisplayName" "$(^Name)"
StrCmp $2 ""
MessageBox MB_OK "This program is already installed. Please uninstall before trying again."
Abort
FunctionEnd
!define PRODUCT_UNINST_KEY "Software\Microsoft\Windows\CurrentVersion\Uninstall\${PRODUCT_NAME}"Note, I've been trying to follow certain examples set on these pages, trying to keep the script as simple as possible:
!define PRODUCT_UNINST_ROOT_KEY "HKLM"
Section -Post
WriteUninstaller "$INSTDIR\uninst.exe"
WriteRegStr ${PRODUCT_UNINST_ROOT_KEY} "${PRODUCT_UNINST_KEY}" "DisplayName" "$(^Name)"
WriteRegStr ${PRODUCT_UNINST_ROOT_KEY} "${PRODUCT_UNINST_KEY}" "UninstallString" "$INSTDIR\uninst.exe"
WriteRegStr ${PRODUCT_UNINST_ROOT_KEY} "${PRODUCT_UNINST_KEY}" "DisplayVersion" "${PRODUCT_VERSION}"
SectionEnd
Are you a developer who uses NSIS to distribute your application? Are you a Winamp plug-in developer who wants to use NSIS to distribute your plug-in? Have suggestions for other people like you? This is the place.
If anyone is willing to take the time to help, I would very much appreciate it.
Thanks much.