Ami
Ami

Reputation: 4259

How to call custom page function in silent installer using NSIS?

    page custom test

    # Installer sections
    Section -Main SEC0000
        SetOutPath $INSTDIR
        MessageBox MB_OK "done"
        ;............
        ;.........
    SectionEnd

    Function test
        MessageBox MB_OK "ok"
        //Do some stuff
    FunctionEnd

    # Installer functions
    Function .onInit
   !ifdef IsSilent
         SetSilent silent
   !endif
         InitPluginsDir
    FunctionEnd

In the above code run both ways silent and non-silent mode. If you run it in non-silent mode [user interaction], custom page function is called and msg box displayed. But if you run it in silent mode[no user interaction], then the custom page is not called and no msg box is displayed. Also, done msg box was displayed in the silent mode.

Is there any reason the custom page isn't called in silent installer?

How to call custom page in silent installer mode?

Upvotes: 2

Views: 1477

Answers (1)

Seki
Seki

Reputation: 11465

Is there any reason is there the custom page did not call in silent installer?

It is by design: a silent installer is silent, i.e. it displays no GUI thus no page is shown (neither standard nor custom) and no page callback is triggered. MessageBox is special as it is mapped to the standard function and was triggered by you.

How to call custom page in silent installer mode?

You cannot. If you have some processing in the custom page, put it in a function:

  • that will be called from the custom page
  • that will be called explicitly from either the .onInit or a section with something like

    IfSilent 0 +2
    Call YourProcessingFunc
    

If you are basing the processing on some choices given by the user in the custom page, you need to use some defaults in silent mode. Or to implement a parameter passing by the command line.

Upvotes: 5

Related Questions