Skip to content
⌘ NSIS Forum Archive

user selects silent vs normal install

10 posts

jackkoho#

user selects silent vs normal install

I am trying to do what I stated in the subject. Currently, I am using an InstallOptions page for the user to select custom vs express install. However, I can't use Silent inside a function and I can't use conditionals outside a function. So I'm not quite sure how to approach this.

I have tried using InstType but it rewrites my SF_SELECTED flags to 0 when I have them set in .onInit.

Jack
goldy1064#
According to the documentation here, you may only set the installer silent during .onInit.

To get around this, you would need a secondary installer that could wrap around your primary. The wrapper installer would just display the custom InstallOptions page you want and pass either a /S or not to the primary installer.
theblazingangel#
perhaps:

1) use the leave function for your install options page to set a global variable which will tell the rest of the script whether it's in normal/express mode
2) use the pre function for other pages to detect express mode, and if so just execute the code and use abort to skip the page (silent)
jackkoho#
this wrapper installer idea is pretty crazy but I am going to give it a shot. Will let you know on any progress.
jackkoho#
The wrapper idea worked!

Here is my code from the wrapper:


;--------------------------------

;Include Modern UI

!include "MUI.nsh"

!include "zipdll.nsh"

!include LogicLib.nsh



;--------------------------------

;General

Name "xxx - v0.9.12"

OutFile "xxxtest-wrapper.exe"







;--------------------------------

;Interface Settings

!define MUI_HEADERIMAGE

!define MUI_HEADERIMAGE_BITMAP "header.bmp" ; optional

!define MUI_ABORTWARNING





;--------------------------------

;Pages

!insertmacro MUI_PAGE_LICENSE "ct_license.txt"

Page custom customvsexpress

!insertmacro MUI_PAGE_INSTFILES

!insertmacro MUI_DEFAULT MUI_FINISHPAGE_TEXT "finishpage text"

!insertmacro MUI_DEFAULT MUI_FINISHPAGE_TITLE "finishpagetitle"

!insertmacro MUI_PAGE_FINISH





;--------------------------------

;Languages

!insertmacro MUI_LANGUAGE "English"





ReserveFile "iotest.ini"

!insertmacro MUI_RESERVEFILE_INSTALLOPTIONS



;--------------------------------

;Variables



Var INI_EXPRESS

Var INI_CUSTOM



#--------------

;Installer Sections



Function customvsexpress

!insertmacro MUI_INSTALLOPTIONS_DISPLAY "iotest.ini"

!insertmacro MUI_HEADER_TEXT "$(TEXT_IO_TITLE)" "$(TEXT_IO_SUBTITLE)"

!insertmacro MUI_INSTALLOPTIONS_READ $INI_CUSTOM "iotest.ini" "Field 1" "State"

!insertmacro MUI_INSTALLOPTIONS_READ $INI_EXPRESS "iotest.ini" "Field 2" "State"

MessageBox MB_OK "$INI_CUSTOM $INI_EXPRESS"

FunctionEnd





Section "xxx" xxx

#call customvsexpress

File setupxxxjacktest.exe

StrCmp $INI_CUSTOM "1" custom silent

custom:

ExecWait "setupxxxjacktest.exe"

goto end

silent:

ExecWait "setupxxxjacktest.exe /S"

end:

SectionEnd




Function .onInit

System::Call 'kernel32::CreateMutexA(i 0, i 0, t "CamerTutorMutex") i .r1 ?e'

Pop $R0

StrCmp $R0 0 +3

MessageBox MB_OK|MB_ICONEXCLAMATION "The installer is already running."

Abort



Pop $0

ClearErrors



!insertmacro MUI_INSTALLOPTIONS_EXTRACT "iotest.ini"





FunctionEnd




LangString TEXT_IO_TITLE ${LANG_ENGLISH} "Express vs. Custom Install"

LangString TEXT_IO_SUBTITLE ${LANG_ENGLISH} "This page allows the user to choose between an express and custom install."



Notice how I left the license page and finish page in the wrapper.
jackkoho#
the one downside to this is that I have some execwaits in my wrapped program that have to install OTHER programs which somewhat ruins the silent experience.
MarkA#
user selects silent vs normal install

Hi,
I have a similar problem in that I would like to be able to automatically decide whether to run a setup as silent or not.

I have a wrapper 'setup.exe' where the user selects which components they would like to install. This works perfectly well. However I would also like to be able to offer the components as separate install files and under this circumstance then the install file should not be silent.

In my wrapper I can add /S to the exec, but how do I make the setup file take notice and not show the welcome page, etc.

Scenario 1 (CD install)
Wrapper.exe (user select components)
run setup1.exe /S (No Welcome page, etc is displayed)
run setup2.exe /S (No Welcome page, etc is displayed)

Scenario 2 (Web install)
User downloads setup1.exe and runs setup1.exe
Welcome page, etc is displayed.

The idea is so that I don't have to keep in sync to separate versions of the same setup.


many thanks
Mark
chivalri#
Non Interactive Installs

Here is what I have done to allow an installer to function in a not silent but not interactive manner.

I have my installer setup so that if I run without any command line variables, it runs as usual; however, if I add a /qb command line option then in onInit I set a variable NonInteractive to "1".

Then I use:
# Installer pages
!define MUI_PAGE_CUSTOMFUNCTION_PRE dirPre
!insertmacro MUI_PAGE_WELCOME
!define MUI_PAGE_CUSTOMFUNCTION_PRE dirPre
!insertmacro MUI_PAGE_LICENSE VILicAgreement.txt
!define MUI_PAGE_CUSTOMFUNCTION_PRE dirPre
!insertmacro MUI_PAGE_DIRECTORY
!define MUI_PAGE_CUSTOMFUNCTION_PRE dirPre
!insertmacro MUI_PAGE_STARTMENU Application $StartMenuGroup
!insertmacro MUI_PAGE_INSTFILES
!define MUI_PAGE_CUSTOMFUNCTION_PRE dirPre
!insertmacro MUI_PAGE_FINISH
!insertmacro MUI_UNPAGE_CONFIRM
!insertmacro MUI_UNPAGE_INSTFILES
Function dirPre
    StrCmp $NonInteractive "1" 0 noskip
    Abort
noskip:
FunctionEnd 
This causes the installer to run and display the status of what is going on but it does not interact with the user and closes automatically when done.
MarkA#
Hi,
thanks for the reply.
I will make some more tests a post the solution when I have it working.

regs
Mark