- NSIS Discussion
- Silent Install Question...
Archive: Silent Install Question...
Jnuw
21st March 2005 17:18 UTC
Silent Install Question...
Hello all.
I am in the process of adding Silent Install support to my installer. I added some functions to allow me to pass the parameter: /COMPS= to my installer. I have 3 sections (for each component), so /COMPS=1 would just install the first section where as /COMPS=12 would do the first two. This works just fine. However if I leave out the /COMPS= parameter or don't set a value for it, the installer runs through, but skips all the sections, which is also fine.
Here is my question: I have the below code in place, but when running the installer in Silent mode, with no components selected (/COMPS=), the message box below does not pop up. I would expect that I would have to deal with this message box with either the IfSilent or /SD commands. I even tried putting a dummy messagebox at the start of the ComponentsLeave function, but it does not come up either. Is this function omitted during a silent install?
Thanks.
!define MUI_PAGE_CUSTOMFUNCTION_LEAVE "ComponentsLeave"
!insertmacro MUI_PAGE_COMPONENTS
Function ComponentsLeave
SectionGetFlags "${SEC01}" $0
StrCmp $0 1 End
SectionGetFlags "${SEC02}" $0
StrCmp $0 1 End
SectionGetFlags "${SEC03}" $0
StrCmp $0 1 End
MessageBox MB_OK|MB_ICONINFORMATION "You must select at least one component."
Abort
End:
FunctionEnd
Jnuw
21st March 2005 17:27 UTC
I noticed this behavior in my DirectoryLeave function too. I'm thinking since these functions are designed to stop the user, and prompt them to make a correction, they must cause a full abort during a silent install since there is no one there to make the correction, and you would have an infinite loop if a full abort as not called. Am I correct?
Afrow UK
21st March 2005 17:44 UTC
Are you unchecking all sections then if /COMPS == "" or if /COMPS is ommited? Because sections are always checked as default...
-Stu
Jnuw
21st March 2005 17:49 UTC
Afrow UK, thanks for the reply. My sections are set to /O, so by default they are all unchecked.
Then after i get the value for the /COMPS parameter, i run this function:
Function SectionSet
StrCmp $2 1 0 +3
SectionSetFlags "${SEC01}" 1
Goto End
StrCmp $2 2 0 +3
SectionSetFlags "${SEC02}" 1
Goto End
StrCmp $2 3 0 +3
SectionSetFlags "${SEC03}" 1
Goto End
StrCmp $2 12 0 +4
SectionSetFlags "${SEC01}" 1
SectionSetFlags "${SEC02}" 1
Goto End
StrCmp $2 13 0 +4
SectionSetFlags "${SEC01}" 1
SectionSetFlags "${SEC03}" 1
Goto End
StrCmp $2 23 0 +4
SectionSetFlags "${SEC02}" 1
SectionSetFlags "${SEC03}" 1
Goto End
StrCmp $2 123 0 +4
SectionSetFlags "${SEC01}" 1
SectionSetFlags "${SEC02}" 1
SectionSetFlags "${SEC03}" 1
End:
FunctionEnd
Afrow UK
21st March 2005 18:03 UTC
That's not a very effecient way of doing it, say if they use /COMPS=321...
Loop:
StrCpy $1 $2 1 -1 #get a num
StrCpy $2 $2 -1 #remove it
StrCmp $1 "" Done
StrCmp $1 1 0 +2
SectionSetFlags "${SEC01}" 1
StrCmp $1 2 0 +2
SectionSetFlags "${SEC02}" 1
StrCmp $1 3 0 +2
SectionSetFlags "${SEC03}" 1
Goto Loop
Done:
Perhaps with NSIS set to silent, all sections are forced to be selected...
Try unchecking them all again before using the above code.
SectionSetFlags "${SEC01}" 0
SectionSetFlags "${SEC02}" 0
SectionSetFlags "${SEC03}" 0
-Stu
Jnuw
21st March 2005 18:24 UTC
Well what i'm finding is that if i run my installer from the command line: Installer.exe /S /COMPS=
The log says:
Skipping section: "1"
Skipping section: "2"
Skipping section: "3"
Which is what i would expect with /COMPS=. But why does the Message box below not pop up?
Function ComponentsLeave
SectionGetFlags "${SEC01}" $0
StrCmp $0 1 End
SectionGetFlags "${SEC02}" $0
StrCmp $0 1 End
SectionGetFlags "${SEC03}" $0
StrCmp $0 1 End
MessageBox MB_OK|MB_ICONINFORMATION "You must select at least one component."
Abort
End:
FunctionEnd
Afrow UK
21st March 2005 18:46 UTC
Oh wait, of course. No page functions are executed on a silent install!
Just put that code into a seperate function, ie Function checkSections, and call that function from both ComponentsLeave and .onInit
Call it in .onInit with IfSilent.
-Stu
Jnuw
21st March 2005 19:11 UTC
Originally posted by Afrow UK
Oh wait, of course. No page functions are executed on a silent install!-Stu
That makes sense, but i'm finding that my DirectoryLeave function below is called when silent...guess I will just have to play with it i bit more.
!define MUI_PAGE_CUSTOMFUNCTION_LEAVE "DirectoryLeave"
!insertmacro MUI_PAGE_DIRECTORY
Thanks for you help.
kichik
22nd March 2005 18:18 UTC
That's impossible, or at least, shouldn't happen. The only place the leave function is called is inside the main dialog's message handler. The dialog isn't even created on silent installation. If it's reproducible, attach a minimal script reproducing this behavior.
Jnuw
22nd March 2005 22:21 UTC
Originally posted by kichik
That's impossible, or at least, shouldn't happen. The only place the leave function is called is inside the main dialog's message handler. The dialog isn't even created on silent installation. If it's reproducible, attach a minimal script reproducing this behavior.
You are correct, I must have been losing it yesterday. Neither of those leave functions are called when installer is silent. Thanks for your time.