Archive: /S = /s = /silent


/S = /s = /silent
Hi,

I want to change the $CMDLINE from /s or /silent to
/S for the real silent install. It's not really my problem, but some users use /s instead /S and the installer should fix this.

I try this, but it don't works:

Function .onInit

goto nach_typ_silent

typ_silent:
StrCpy $CMDLINE /S

nach_typ_silent:

Call GetParameters
Pop $0
StrCmp $0 "/S" end_function
StrCmp $0 "/silent" typ_silent
StrCmp $0 "/s" typ_silent
StrCmp $0 "/a" end_function
StrCmp $0 "/anything" end_function
StrCmp $0 "-offline" end_function
StrCmp $0 "-online" end_function
; !define UPDATEUI_CMDLINE $0
; Exec "My_Install_Package.exe /S"
MessageBox MB_OK|MB_ICONEXCLAMATION "Unzulässiger Programmstart!"
Abort

end_function:

FunctionEnd


Thanks.

-timecop


NSIS doesn't read the command line after .onInit, only before it. In the next CVS version you will be able to use SetSilent to do the same (already available in the newstuff version).


Wonderful, thanks.


>> NSIS doesn't read the command line after .onInit

where else then?


Just before.


.onGUIinit or so?

i dont know so i asked

.oninit is for me the first section executed on startup.


.onGUIInit comes after .onInit, it's before that too. .onInit is the first script code executed, but it's certainly not the first thing the installer does. Lots of stuff have to be initialized before .onInit will be useable, including the command line processing. Take $INSTDIR for example. You depend on $INSTDIR to be initalized in .onInit but it can be changed by the command line, InstallDir and InstallDirRegKey. All three of those have to be checked to make sure the directory is valid too.


<confused>

i know some settings before .oninit is used.

For that script at the beginning of this topic - i just have to put a "CALL ..." somewhere near "Installdir '...'" or so?


!define MUI_PRODUCT "my xxx"
!define MUI_VERSION "1.0"
!define MUI_ICON "x.ico"
!define MUI_UNICON "x.ico"

!include "MUI.nsh" ;important for the new MUI
!include "Sections.nsh" ;important for section select or deselect

!define TEMP1 $R1
!define TEMP2 $R2
!define TEMP3 $R3
!define TEMP4 $R4

;--------------------------------
;Configuration

;General
OutFile "xxx.exe"
InstallDir "$PROGRAMFILES\${MUI_PRODUCT}"

CALL ...

I'm sorry, I don't understand... Call what? What does this has to do with silent installation? What does it has to do with defines?


damn

so i ask other way:

how do i initiate a /S (silent) installation in script?


SetSilent


Use SilentInstall/SilentUninstall if you want it to always be silent. Use the latest CVS version and SetSilent if you want it to be silent according to some check you'd preform on runtime.


hmm

>> all sections that have the SF_SELECTED flag are installed quietly

So the panes with path and other stuff will processed silent too? (no input/no output)

but what have i to do when i asks this flag (/S) manually in .onInit?

When do i need $CMDLINE or how can i turn left while "not silent" is right?

The idea behind is that i have a program with own panes (from IO) and i dont want to create routines twice when i am able to do the silent way in same program.

i hope this was not to complicated.


I hope I understand what you're asking, tell me if I'm way off.

The /S command line switch is process by NSIS, you don't need to process it alone.

To automatically fill in information that you get from InstallOptions in non-silent mode you shuold use IfSilent. If the installation is silent you should of course supply defaults. If you want you can also process $CMDLINE, allowing the user to provide input on the command line.

You can also use "SetSilent normal" in .onInit to prevent the installer from being silent.


hmm again ;)

;Modern UI Configuration

page custom selectaction

page custom save01
page custom save02
page custom save03
page custom save04
page custom save05

;page custom restore01
;page custom restore02
;page custom restore03
;page custom restore04


This is what i have so far.

Saving routines are working but they have user-input (options to save different files and folder input).

Default is all files ticked and folder (if not given) from registry.

All settings are saved in a ini-file.

with a silent install i have to bypass the user-input like this:

page custom save01
page custom save01_silent

So "save01" compares if a silent flag has been set and skips while "save01_silent" skips not.

i hope i made clear why i am asking where *before* .onInit the decision is made.

if "/S" is the only flag for a silent setup i would use "/s" (lower case) or "/silent" (from example on top) and $CMDLINE to differentiate (what a word - to differ?) the way it goes.

thank you for your patience :)

Page functions won't be called on a silent installation. You should probably add something like this to your first section or .onInit:

IfSilent 0 notSilent
Call save01_silent
Call save02_silent
notSilent:


I still don't understand why you want to know where before .onInit /S is processed. How can it help you? It's in Source\exehead\Main.c line 111.

if "/S" is the only flag for a silent setup i would use "/s" (lower case) or "/silent" (from example on top) and $CMDLINE to differentiate (what a word - to differ?) the way it goes.
Do you want to add those switches on top what NSIS already processes? If so, simply use this in .onInit:

Call GetParameters
Pop $0
StrCmp $0 "/s" silent
StrCmp $0 "/silent" silent
Return
silent:
SetSilent silent


Note that StrCmp is case insensitive and that this will not work if the user specifies more than one swtich (for example: myinstaller.exe /silent /D=C:\Program Files\InstDir). To make it work with more than one switch use StrStr. You can find it in the manual.

Call GetParameters
Pop $0
StrCmp $0 "/s" silent
StrCmp $0 "/silent" silent
Return
silent:
SetSilent silent



IfSilent 0 notSilent
;silent stuff
notSilent:


i think this is the solution for my problem - thank you very much.

BTW are we talking about this GetParameters from Appendix_B ?

 ; GetParameters
; input, none
; output, top of stack (replaces, with e.g. whatever)
; modifies no other variables.

Function GetParameters
Push $R0
Push $R1
Push $R2
StrCpy $R0 $CMDLINE 1
StrCpy $R1 '"'
StrCpy $R2 1
StrCmp $R0 '"' loop
StrCpy $R1 ' ' ; we're scanning for a space instead of a quote
loop:
StrCpy $R0 $CMDLINE 1 $R2
StrCmp $R0 $R1 loop2
StrCmp $R0 "" loop2
IntOp $R2 $R2 + 1
Goto loop
loop2:
IntOp $R2 $R2 + 1
StrCpy $R0 $CMDLINE 1 $R2
StrCmp $R0 " " loop2
StrCpy $R0 $CMDLINE "" $R2
Pop $R2
Pop $R1
Exch $R0
FunctionEnd


------------------------------------

>> I still don't understand why you want to know where before .onInit /S is processed.

The problem for me was to understand that NSIS uses /S internal and skips sections silent. This i meant with "before". i thought it can be used manually before .onInit is used. :igor:

Yes, this is the GetParameters we are talking about.