gpt4 book ai didi

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

转载 作者:行者123 更新时间:2023-12-04 23:33:58 24 4
gpt4 key购买 nike

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

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

有没有办法制作编译时“IfExist”类型的逻辑?

最佳答案

!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

注意:这里使用的 !system 命令假设您是在 Windows 上编译

关于基于文件存在的 NSIS 脚本条件编译,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/1102654/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com