NSIS 基础知识出错

NSIS basics go wrong

所以这是一个非常基本的问题,但我似乎找不到我做错了什么。

所以我在 NSIS 中摆弄定义,但它没有像我预期的那样工作,所以我已将问题缩小到最小的部分,但我仍然无法使它像我预期的那样工作。

脚本如下所示:

!ifndef b
!define b ""
!endif

!if $b=="b"
!define a "b"
!else
!define a "c"
!endif

Section
    MessageBox MB_OK "a: ${a} b: ${b}"
SectionEnd

我运行它带有标志/Db=b

输出仍然是:

a: "c" b: "b"

我遗漏了一些微不足道的东西!

b 是定义,不是变量:

!ifndef b
!define b ""
!endif

!if "${b}" == "b"    # <-- Modify this line.
!define a "b"
!else
!define a "c"
!endif

Section
    MessageBox MB_OK "a: ${a} b: ${b}"
SectionEnd

此外,我建议您在使用 if 时引用所有内容,因为如果定义(或变量的值)为空,它会给出错误。