Archive: silent install and InstallOptions


silent install and InstallOptions
hello,

i have an installer. it containes a custom page, besides the standard pages.
i want to add silent support to it. when i install it with the /S parameter, the installer jumps over the custom page.
is this normal in silent installs ?
i tried with InstallOptions.nsi from the Examples\Modern UI and i get the same result.
i am using NSIS 2.14.

thanks,
OJi.


This sounds like expected behavior. If you have functionality in your custom page function, you can move it to another function or section that will still get executed when your installer is run silently. Otherwise, isn't not displaying pages what you want with /S?


Otherwise, isn't not displaying pages what you want with /S?
i do not want the page to be displayed. this is why i use silent. but i want the code inside the custom page to be executed.
i have a custom page where the user selects aditional options.
if i use silent, the installer does not enter the custom page function.

thanks,
OJi.

I'd suggest creating a function for your additional options. You can have your custom page function call this function, so it will work when run non-silently.

Then add IfSilent (docs sec 4.9.4.12) and call your additional options function if the silent flag is set, so this code will also be executed when you run silently.


Originally posted by dienjd
I'd suggest creating a function for your additional options. You can have your custom page function call this function, so it will work when run non-silently.

Then add IfSilent (docs sec 4.9.4.12) and call your additional options function if the silent flag is set, so this code will also be executed when you run silently.
i already did everything you said.
i use a function in a custom page, i use IfSilent. but the custom page is totaly skipped in silent mode !
try with the InstallOptions.nsi example in the Examples\ModernUI folder.
put a MessageBox in any custom page. without the /SD parameter!
run it normaly. the message box is displayed.
now run it in silent mode. the message box is not displayed. the only message box displayed is from the "Dummy section".

Please try this. i cannot explain this more, my english is limited.

thanks,
OJi.

Here's what I meant. Not pretty, but it seems like it would work:


Function IWillAlwaysBeCalled
IfSilent 0 nonsilent
#explicitly set additional options to selected
Goto done
nonsilent:
#conditionally set additional options based on user's input
done:
FunctionEnd


#somewhere that always gets run, like .onInit
IfSilent
Call IWillAlwaysBeCalled


Function MyCustomPage
#your custom page UI code, if any
IfSilent +2
Call IWillAlwaysBeCalled
FunctionEnd

from your example:

in silent mode the "Function MyCustomPage" it is skipped (it is not parsed).
just try with the InstallOptions example.

thanks,
OJi.


Try compiling this and running with and without a '/S'


Name "silenttest"
OutFile "silenttest.exe"

Var custompageviewed

Page instfiles
Page custom MyCustomPage

Section ""
SectionEnd

Function .onInit
IfSilent 0
Call SetAdditionalOptions
FunctionEnd

Function SetAdditionalOptions
IfSilent 0 nonsilent
#explicitly set additional options to selected
MessageBox MB_OK "silent, but working"
Goto done
nonsilent:
StrCmp $custompageviewed "1" 0 done
#conditionally set additional options based on user's input
MessageBox MB_OK "non-silent"
done:
FunctionEnd

Function MyCustomPage
StrCpy $custompageviewed "1"
MessageBox MB_OK "this is my custom page code"
IfSilent +3
Call SetAdditionalOptions
FunctionEnd

i understand now what you mean.
but still, why if you delete the Call line from .onInit, nothing from Function MyCustomPage gets executed ?
is this a bug ? this is how it should be ? please explain

thanks again,
OJi


This is how things should work. This line calls the MyCustomPage function:

Page custom MyCustomPage

Since it's a page command, it _should_ get skipped when running silently.


thanks for replying

ok. i get it. the custom page is skipped when doing a silent install.
i do not agree with you. it should not be skipped. (my opinion)

i have options that depend on what sections were selected. if a section was not selected, the option (checkbox, radio button) is disabled... it's a complicated script... :)
i use a text file for the user to select the sections for install.
this is not good. i have to rewrite a lot of code. i did not knew custom pages were skipped.
well, it's gonna be a long week...

again, many many thanks !
OJi.