I want to compare two strings in NSIS, For example.How to do if else condition for the below code.
ReadRegStr $R0 HKLM "${PRODUCT_UNINST_KEY}" "InstallLocation"
if ;$R0 has some values then it needs to be copied else this " $INSTDIR "$PROGRAMFILES64\${PRODUCT_NAME}""values should be assigned to INSTDIR
StrCpy $INSTDIR "$R0"
else
StrCpy $INSTDIR "$PROGRAMFILES64\${PRODUCT_NAME}"
The StrCmp
and StrCmpS
instructions can be used to compare strings:
StrCmp $myvar "somestring" 0 jump_to_if_not_equal
DetailPrint "myvar was somestring"
goto end
jump_to_if_not_equal:
DetailPrint "not a match"
end:
You can also use the LogicLib helper macros:
!include LogicLib.nsh
${If} $myvar == "something"
DetailPrint "match"
${Else}
DetailPrint "not a match"
${EndIf}