Old 4th September 2003, 17:28   #1
timecop12
Junior Member
 
Join Date: Jun 2003
Location: Germany
Posts: 20
/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
timecop12 is offline   Reply With Quote
Old 4th September 2003, 17:31   #2
kichik
M.I.A.
[NSIS Dev, Mod]
 
kichik's Avatar
 
Join Date: Oct 2001
Location: Israel
Posts: 11,343
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).

NSIS FAQ | NSIS Home Page | Donate $
"I hear and I forget. I see and I remember. I do and I understand." -- Confucius
kichik is offline   Reply With Quote
Old 4th September 2003, 17:50   #3
timecop12
Junior Member
 
Join Date: Jun 2003
Location: Germany
Posts: 20
Wonderful, thanks.
timecop12 is offline   Reply With Quote
Old 4th September 2003, 19:57   #4
Brummelchen
Major Dude
 
Join Date: May 2003
Posts: 681
>> NSIS doesn't read the command line after .onInit

where else then?

Greets, Brummelchen
Brummelchen is offline   Reply With Quote
Old 4th September 2003, 20:11   #5
kichik
M.I.A.
[NSIS Dev, Mod]
 
kichik's Avatar
 
Join Date: Oct 2001
Location: Israel
Posts: 11,343
Just before.

NSIS FAQ | NSIS Home Page | Donate $
"I hear and I forget. I see and I remember. I do and I understand." -- Confucius
kichik is offline   Reply With Quote
Old 5th September 2003, 00:12   #6
Brummelchen
Major Dude
 
Join Date: May 2003
Posts: 681
.onGUIinit or so?

i dont know so i asked

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

Greets, Brummelchen
Brummelchen is offline   Reply With Quote
Old 5th September 2003, 10:02   #7
kichik
M.I.A.
[NSIS Dev, Mod]
 
kichik's Avatar
 
Join Date: Oct 2001
Location: Israel
Posts: 11,343
.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.

NSIS FAQ | NSIS Home Page | Donate $
"I hear and I forget. I see and I remember. I do and I understand." -- Confucius
kichik is offline   Reply With Quote
Old 5th September 2003, 17:28   #8
Brummelchen
Major Dude
 
Join Date: May 2003
Posts: 681
<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?

code:

!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 ...


Greets, Brummelchen
Brummelchen is offline   Reply With Quote
Old 5th September 2003, 18:59   #9
kichik
M.I.A.
[NSIS Dev, Mod]
 
kichik's Avatar
 
Join Date: Oct 2001
Location: Israel
Posts: 11,343
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?

NSIS FAQ | NSIS Home Page | Donate $
"I hear and I forget. I see and I remember. I do and I understand." -- Confucius
kichik is offline   Reply With Quote
Old 5th September 2003, 20:33   #10
Brummelchen
Major Dude
 
Join Date: May 2003
Posts: 681
damn

so i ask other way:

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

Greets, Brummelchen
Brummelchen is offline   Reply With Quote
Old 5th September 2003, 20:35   #11
Joost Verburg
NSIS MUI Dev
 
Join Date: Nov 2001
Posts: 3,717
SetSilent
Joost Verburg is offline   Reply With Quote
Old 5th September 2003, 20:35   #12
kichik
M.I.A.
[NSIS Dev, Mod]
 
kichik's Avatar
 
Join Date: Oct 2001
Location: Israel
Posts: 11,343
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.

NSIS FAQ | NSIS Home Page | Donate $
"I hear and I forget. I see and I remember. I do and I understand." -- Confucius
kichik is offline   Reply With Quote
Old 5th September 2003, 21:52   #13
Brummelchen
Major Dude
 
Join Date: May 2003
Posts: 681
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.

Greets, Brummelchen
Brummelchen is offline   Reply With Quote
Old 5th September 2003, 21:59   #14
kichik
M.I.A.
[NSIS Dev, Mod]
 
kichik's Avatar
 
Join Date: Oct 2001
Location: Israel
Posts: 11,343
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.

NSIS FAQ | NSIS Home Page | Donate $
"I hear and I forget. I see and I remember. I do and I understand." -- Confucius
kichik is offline   Reply With Quote
Old 5th September 2003, 22:12   #15
Brummelchen
Major Dude
 
Join Date: May 2003
Posts: 681
hmm again

code:
;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

Greets, Brummelchen
Brummelchen is offline   Reply With Quote
Old 5th September 2003, 22:20   #16
kichik
M.I.A.
[NSIS Dev, Mod]
 
kichik's Avatar
 
Join Date: Oct 2001
Location: Israel
Posts: 11,343
Page functions won't be called on a silent installation. You should probably add something like this to your first section or .onInit:

code:
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.

Quote:
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:

code:
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.

NSIS FAQ | NSIS Home Page | Donate $
"I hear and I forget. I see and I remember. I do and I understand." -- Confucius
kichik is offline   Reply With Quote
Old 5th September 2003, 22:58   #17
Brummelchen
Major Dude
 
Join Date: May 2003
Posts: 681
code:
Call GetParameters
Pop $0
StrCmp $0 "/s" silent
StrCmp $0 "/silent" silent
Return
silent:
SetSilent silent




code:
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 ?

code:
; 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.

Greets, Brummelchen
Brummelchen is offline   Reply With Quote
Old 6th September 2003, 08:19   #18
kichik
M.I.A.
[NSIS Dev, Mod]
 
kichik's Avatar
 
Join Date: Oct 2001
Location: Israel
Posts: 11,343
Yes, this is the GetParameters we are talking about.

NSIS FAQ | NSIS Home Page | Donate $
"I hear and I forget. I see and I remember. I do and I understand." -- Confucius
kichik is offline   Reply With Quote
Reply
Go Back   Winamp & Shoutcast Forums > Developer Center > NSIS Discussion

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump