IfFileExists Changes Section Flags: Difference between revisions
From NSIS Wiki
Jump to navigationJump to search
Line 28: | Line 28: | ||
IfFileExists C:\autoexec.bat AutoexecExists PastAutoexecCheck | IfFileExists C:\autoexec.bat AutoexecExists PastAutoexecCheck | ||
AutoexecExists: | AutoexecExists: | ||
; This is what is done by sections.nsh SelectSection macro | |||
SectionGetFlags "${autoexec_detected}" $0 | SectionGetFlags "${autoexec_detected}" $0 | ||
IntOp $0 $0 | ${SF_SELECTED} | IntOp $0 $0 | ${SF_SELECTED} | ||
Line 35: | Line 36: | ||
IfFileExists C:\boot.ini BootExists PastBootCheck | IfFileExists C:\boot.ini BootExists PastBootCheck | ||
BootExists: | BootExists: | ||
; Use the macro from sections.nsh | |||
!insertmacro SelectSection ${boot_detected} | !insertmacro SelectSection ${boot_detected} | ||
Latest revision as of 16:54, 4 February 2006
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