I'm writing an NSIS installer script to install some network printers. I want each printer to be installed as an optional Section
, but I don't want to restart the print spooler more than once. So, I created a hidden section that checks if each printer section is selected, and if it is then it includes the registry settings to create the port for that printer. Then it restarts the print spooler. The problem is I need this hidden section to be done first, but I also need to use the section indexes of the printer sections.
Does anyone know how I can reference the section indexes before the sections are defined? Another approach I thought of was to move the hidden section to the end, but then I would need a way to make sure it's installed first. Any help or ideas would be appreciated.
Section "-"
${IfThen} ${SectionIsSelected} ${Sec01} ${|} !include "10.0.0.8.nsh" ${|}
${IfThen} ${SectionIsSelected} ${Sec02} ${|} !include "10.0.0.11.nsh" ${|}
nsExec::Exec 'net stop spooler'
nsExec::Exec 'net start spooler'
SectionEnd
Section "My Printer" Sec01
ExecWait 'rundll32 printui.dll,PrintUIEntry /if /b "My Printer" /f "$EXEDIR\oj8000\hpoj800z.inf" /r "10.0.0.8" /m "HP Officejet Pro 8000 A809 Series" /z'
SectionEnd
Section "Copier" Sec02
ExecWait 'rundll32 printui.dll,PrintUIEntry /if /b "Copier" /f "$EXEDIR\copier\oemsetup.inf" /r "10.0.0.11" /m "RICOH Aficio MP C4000 PCL 6" /z'
SectionEnd
Section -
...
call doSectionChecks
SectionEnd
Section "My Printer" Sec01
...
SectionEnd
Function doSectionChecks
... ${Sec01}
FunctionEnd