NSIS脚本条件编译基于文件的存在

Ray*_*yes 4 nsis

我有一个基于NSIS的安装程序,我需要能够在不同的条件下生成略有不同的版本.

条件很容易在编译时建立,如果磁盘上存在特定文件,则可以使用替代品牌.我知道我可以使用makensis.exe的命令行选项来提供这种行为,但如果编译器可以为我处理这个问题会更好.

有没有办法使编译时"IfExist"类型逻辑?

And*_*ers 6

!macro CompileTimeIfFileExist path define
!tempfile tmpinc
!system 'IF EXIST "${path}" echo !define ${define} > "${tmpinc}"'
!include "${tmpinc}"
!delfile "${tmpinc}"
!undef tmpinc
!macroend

Section 
!insertmacro CompileTimeIfFileExist "$%windir%\explorer.exe" itsThere
!ifdef itsThere
MessageBox mb_Topmost yes
!else
MessageBox mb_Topmost no
!endif
SectionEnd
Run Code Online (Sandbox Code Playgroud)

注意:此处使用的!system命令假定您正在Windows上进行编译