Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to compare two string in NSIS [duplicate]

Tags:

nsis

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}"
like image 975
Raj Avatar asked Sep 13 '25 18:09

Raj


1 Answers

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}
like image 78
Anders Avatar answered Sep 15 '25 21:09

Anders