Skip to content
⌘ NSIS Forum Archive

change ${PRODUCT_UNINST_KEY} programmatically

5 posts

orecchionebruno#

change ${PRODUCT_UNINST_KEY} programmatically

Hello, during Uninistaller creation I would like to change the
${PRODUCT_UNINST_KEY}
because for reasons this installer should be allowed to be installed several times and in different folders.... we can say that it's like an add-on.

So to have an unique uninstaller for unique path, I thought to convert the
InstallPath
as Hex value:

${StrFilter} $INSTDIR "-" "" "" $R0
;convert to Hexadecimal
${registry::StrToHex} $R0 $HexPathValue
${registry::Unload}​
well, now I would like to change
${PRODUCT_UNINST_KEY}
like
${PRODUCT_UNINST_KEY} = "${PRODUCT_UNINST_KEY} $HexPathValue"
so I tried to use
StrCpy
command but this is wrong.

I don't want to do something like this:
WriteRegStr ${PRODUCT_UNINST_ROOT_KEY} "${PRODUCT_UNINST_KEY} $HexPathValue" "DisplayName" "$(^Name)"
Can you please explain me how to do that?

By the way the value should be used automatically by the uninistalller later after to have wrote these strings:

WriteRegStr ${PRODUCT_UNINST_ROOT_KEY} "${PRODUCT_UNINST_KEY}" "Path" "$INSTDIR"
WriteUninstaller "$INSTDIR\Program\Uninstall${PRODUCT_NAME} ${PRODUCT_VERSION}.exe"
WriteRegStr ${PRODUCT_UNINST_ROOT_KEY} "${PRODUCT_UNINST_KEY}" "DisplayName" "$(^Name)"
WriteRegStr ${PRODUCT_UNINST_ROOT_KEY} "${PRODUCT_UNINST_KEY}" "UninstallString" "$INSTDIR\Program\Uninstall${PRODUCT_NAME} ${PRODUCT_VERSION}.exe"
WriteRegStr ${PRODUCT_UNINST_ROOT_KEY} "${PRODUCT_UNINST_KEY}" "DisplayVersion" "${PRODUCT_VERSION}"
Thank you in advance for the explanation
orecchionebruno#
ok thank you Anders I understand it, but if I would like to reDefine it, how can I do it?
Anders#
Var myunkey
Section
StrCpy $myunkey "Software\Microsoft\Windows\CurrentVersion\Uninstall\MyApp"
${If} ...
  StrCpy $myunkey "Software\Microsoft\Windows\CurrentVersion\Uninstall\$0blahblah$1whatever"
${EndIf}
WriteRegStr HKLM $myunkey UninstallString '"$instdir\Uninstall.exe"'
WriteRegStr ...
SectionEnd 
The uninstaller does not automatically know the name of the key, you have to write it to a .ini in $InstDir and read it back into $myunkey in the uninstaller with the NSIS ini functions.