Archive: Silent setup for GUI installation


Silent setup for GUI installation
Hi All,

We have simple setup with licensing page, product directory select and reboot confirmation pages. For remote SILENT install we need make answers file for each page.
I don't understand How to use SF_SELECTED attribute for section. Any suggestions?


I didn't test this but it should work:


Function .onInit
IfFileExists "$EXEDIR\silent.ini" "" no_silent_install
/*
Read here the stuff from the silent file
*/
Call Install_Function
Quit
no_silent_install:
FunctionEnd

Function Install_Function
/*
Place here all the stuff you would normally put in the main section.
*/
FunctionEnd


Section
Call Install_Function
/*
Should call the Install_Function here too for normal installations. This way changes of the install process have to be edited on only one place
*/
SectionEnd


Originally posted by flizebogen
I didn't test this but it should work:

Function .onInit
IfFileExists "$EXEDIR\silent.ini" "" no_silent_install
/*
Read here the stuff from the silent file
*/
Call Install_Function
Quit
no_silent_install:
FunctionEnd

Function Install_Function
/*
Place here all the stuff you would normally put in the main section.
*/
FunctionEnd


Section
Call Install_Function
/*
Should call the Install_Function here too for normal installations. This way changes of the install process have to be edited on only one place
*/
SectionEnd

Not clear :(
What is answers file? For example: first Welcome scren, user must press Next button. What instruction can do it? Hide Welcome screeen and pres button?

If you want to provide an silent installation you need all neccessary informations. Store them in the ini file (They are very easy to process in NSIS).

The Function .on.Init is executed BEFORE any GUI is shown up. Thats why i used IfFileexists.

And the Quit Command after the function call but within .onInit terminate the installer. This way you can install your app without any screen (silent).

If you write your install commands in the Install_Function as i suggested you only have to call this function within you section for normal installations. This solutions works only if you're using one section. For more sections its a little bit tricky but possible.


Originally posted by flizebogen
If you want to provide an silent installation you need all neccessary informations. Store them in the ini file (They are very easy to process in NSIS).

The Function .on.Init is executed BEFORE any GUI is shown up. Thats why i used IfFileexists.

And the Quit Command after the function call but within .onInit terminate the installer. This way you can install your app without any screen (silent).

If you write your install commands in the Install_Function as i suggested you only have to call this function within you section for normal installations. This solutions works only if you're using one section. For more sections its a little bit tricky but possible.
Thanks a lot :) It's easy and fast method. But we have more than one section. And I asked about standart NSIS features

4.12 Silent Installers/Uninstallers

....
If your installer/uninstaller requires a lot of information and you want it to be able to be silent, you should allow the user to pass on a path to an answers file. This would be much more comfortable than writing all of the information on the command line.


What is answer file? Is it instruction for page control (press next button, select reboot radiobutton on last page) and DON'T SHOW pages

An answer file is a text file that provides any neccessary infos.

NSIS is a scripting language that offers less "automatic" flow-control. If the standard installer behaviour isn't enough than you have to modify the script to fit you needs.

I know what you want - i've seen it in a lot of installers, but most of them had very complex scripts to do the job. There is no "Record" function like in Installshield to give you an answer file.

It's better to make a combined normal and silent script based on my example than to think about how to alter a specific control in a normal installation.


Ok.
As I understand, NSIS doesn't support REAL silent installation with easy swith key /s :( One setup that can work in GUI mode or silent mode.


Is does support /s switch but your script must react on it, because on silent mode not all commands are working i.e page based commands.

As i said there is no "automagically" Record and play modus.

Hence it is very flexible (more than i.e. Innosetup) but it requires a lot more scripting code.


And What about this way for one code but different build options:
1. Set macro SILENT and run 2 NSIS build One /SILENT another without /SILENT macro
2. Hide all pages
!ifndef SILENT
!insertmacro MUI_PAGE_WELCOME
!insertmacro MUI_PAGE_LICENSE "License.rtf"
!insertmacro MUI_PAGE_DIRECTORY
!insertmacro MUI_PAGE_INSTFILES
!insertmacro MUI_PAGE_FINISH
!endif
3. Left all section as is
...
Copy files
Create registry key
...
4. Get InstallFolder due setup paramenter setup.exe /d="c:\programm files\..."
5. Get Reboot needs due /reboot paramenter
setup.exe /reboot

What do u think? One source code and 2 different installers


It's possible to split it this way because !define is a compile-time command but you will need to check for the silent define in different places

- MUI macros
- Pages commands
- Page related commands as LicenceText


I try

!ifdef SILENT
Silentinstall silent
!endif

Everything work without additional setting - no visiblt pages :)