知道一个部分是否已经执行了另一个部分

Knowing in a Section if another Section has already been executed

我想为我们开发的各种应用程序创建一个套件安装程序。结构如下:

用户可以选择安装他想要的任何应用程序,或多个。我知道如何为此使用 Sections。如果用户只选择应用程序 A,或者选择应用程序 A 和 B 或 C,这将正常工作。但是,如果用户选择应用程序 B 和 C,我想避免驱动程序 2 被提示安装两次。

有办法实现吗?比如是否可以知道什么时候执行了应用程序C的段,应用程序B的段已经执行完了,不需要再安装驱动2了?

可能有很多方法可以解决这个问题,一种是将驱动程序放在一个隐藏的部分,确保它处于正确的状态:

!include LogicLib.nsh
!include Sections.nsh
!include x64.nsh

Page Components
Page Directory
Page InstFiles

Section "-Driver2" SID_DRIVER2
${If} ${IsNativeAMD64}
    ; Install AMD64 64-bit driver/library
${ElseIf} ${IsNativeARM64}
    ; Install ARM64 64-bit driver/library
${ElseIf} ${IsNativeIA32}
    ; Install i386 32-bit driver/library
${Else}
    Abort "Unsupported CPU architecture!"
${EndIf}
SectionEnd

Section "App B" SID_APPB
SectionEnd

Section /o "App C" SID_APPC
SectionEnd

Function .onSelChange
${If} ${SectionIsSelected} ${SID_APPB}
${OrIf} ${SectionIsSelected} ${SID_APPC}
    !insertmacro SelectSection ${SID_DRIVER2}
${Else}
    !insertmacro UnselectSection ${SID_DRIVER2}
${EndIf}
FunctionEnd

Function .onInit
Call .onSelChange ; Make sure things are configured correctly in silent installers
FunctionEnd