IfFileExists Changes Section Flags
From NSIS Wiki
Jump to navigationJump to search
Description
IfFileExists determines whether certain component sections are checked or unchecked.
The Script
!include Sections.nsh Name TestSelectSection OutFile "TestSelectSection.exe" Page components Page instfiles ShowInstDetails show ; This file will exist on most computers Section /o "autoexec.bat detected" autoexec_detected MessageBox MB_OK autoexec SectionEnd Section /o "Boot.ini detected" boot_detected MessageBox MB_OK boot SectionEnd Section /o "non-existing file detected" missing_detected MessageBox MB_OK missing SectionEnd Function .onInit IfFileExists C:\autoexec.bat AutoexecExists PastAutoexecCheck AutoexecExists: ; This is what is done by sections.nsh SelectSection macro SectionGetFlags "${autoexec_detected}" $0 IntOp $0 $0 | ${SF_SELECTED} SectionSetFlags "${autoexec_detected}" $0 PastAutoexecCheck: IfFileExists C:\boot.ini BootExists PastBootCheck BootExists: ; Use the macro from sections.nsh !insertmacro SelectSection ${boot_detected} PastBootCheck: IfFileExists C:\xyz_missing.xyz MissingExists PastMissingCheck MissingExists: !insertmacro SelectSection ${missing_detected} PastMissingCheck: FunctionEnd