RossW
19th June 2006 21:49 UTC
Installer Wrapper that calls other NSIS installs?
Is it possible to write a 'wrapper' script that can run other NSIS setup.exe's? If the wrapper script has the Licence and Directory pages, can I pass in the parent directory chosen in the wrapper to the individual installers so that they're silent installs, but if the called installers were invoked directly they would still display the Licence & Directory pages (the latter is less of a requirement than the ability to pass in the parent directory and do a silent install)
Afrow UK
19th June 2006 22:47 UTC
This should be quite simple.
The wrapper executable executes the silent installer with Exec in the Directory pages' Leave function and then calls Quit. Before calling Exec it should store the entered installation path ($INSTDIR) under a temporary registry key (using WriteRegStr).
The silent installer when executed checks for the presence of this key (ReadRegStr). If the error flag is set (by using IfErrors - make sure to call ClearErrors first before ReadRegStr!) then it executes the wrapper installer itself and then quits (can all be done in .onInit).
Naturally, if the registry key does exist and a value that isn't empty is read (in the silent installer .onInit), then the registry key should be deleted so that the silent installer cannot be executed again without displaying the License and Directory pages.
-Stu
RossW
20th June 2006 03:08 UTC
Thanks Stu!
A few follow-up questions (I'm new to NSIS, so please pardon my obtuseness):
1) Do I have to do anything special in the actual installers to allow for silent install?
2) Rather than use a temp reg entry, could I use arguments in the Exec statement?
3) Would there be some sample code for any of this, particularly for the oinit function that calls the section installer directly?
Cheers,
Ross
stb
20th June 2006 07:48 UTC
ad 1) You should use /SD for message boxes and must be aware that not all call backs run in silent mode (if you have advanced page call back functions defined). If you have only simple installers you have just to check the message boxes (see NSIS help).
ad 2) Yes, see NSIS help for silent mode (/D).
ad 3) You can't call a section directly. You can disable/enable any installer pages (directory selection, welcome screen), at a minimum you need INSTFILES.
RossW
20th June 2006 14:54 UTC
Just to be clear, I can run an install script directly (with licence page 'I Agree' button') but also silently where that page will be bypassed?
Also, if I add code to the Directory page's Leave function to call the individual installers in silent mode, how do I determine which 'components' the user checked? For example, my wrapper installer could list 3 'components' but they only check one of them, so how do I know to run just that selection's installer?
stb
20th June 2006 15:23 UTC
Yes, have a look at the NSIS help. The "silent mode" can be set by NSIS script (compile time/run time) and/or by command line option. No page will show up if the installer is in silent mode.
You cannot/should not drop install code in the Leave function because Leave is a call back and will (?) not be called in silent mode. It is bad behaviour, too. All code which effectively installs files or settings should be in Sections.
Make one section for each of the sub-installers and call the sub-installers with ExecWait within the Section area.
See NSIS help or examples for Sections (how to define defaults etc.)
farialima
22nd June 2006 21:30 UTC
If a wrapper calls other NSIS installers, isn't the install size wrong ?
I think that there's a small issue with such a setup, namely that the disk space required for installation will be wrong, potentially leading the installer to run even if there's not enough disk space.
Let me try to explain:
The setup that you are proposing is, if I'm correct, to have a "wrapper" installer contain other installers, that will be unpacked, silently run, and (I suppose) deleted once they have run.
The user will choose the install location in the "wrapper" installer. So when NSIS computes the disk space size needed to install, he will do it in the "wrapper" installer, and it will be the installed size of the wrapper installer - i.e. the size of all the sub-installers.
Instead, it should be the size of all the files contained in all the subinstallers, because ultimately, that's the space that will be used on disk !
Furthermore, I suppose that, during installation, the temporary disk space needed is:
- the space for the sub-installers "setup.exe"
- plus the space of the files installed by the sub-installers.
Which means that, even if there's enough disk space overall, there's a risk that the installation will fail because there's *temporary* not enough disk space.
Am I correct ? If yes, would you have any idea on how to fix that ?
It seems like a small issue, but you don't want to lie to your users in terms of needed disk space...
thanks
stb
22nd June 2006 21:46 UTC
Yes. "SectionSetSize" is your friend (see NSIS help).