root / tmp / org.txm.setups / nsis-2.5 / Examples / silent.nsi @ 3030
Historique | Voir | Annoter | Télécharger (2,17 ko)
1 |
# This example shows how to handle silent installers. |
---|---|
2 |
# In short, you need IfSilent and the /SD switch for MessageBox to make your installer |
3 |
# really silent when the /S switch is used. |
4 |
|
5 |
Name "Silent" |
6 |
OutFile "silent.exe" |
7 |
RequestExecutionLevel user |
8 |
|
9 |
# uncomment the following line to make the installer silent by default. |
10 |
; SilentInstall silent |
11 |
|
12 |
Function .onInit |
13 |
# `/SD IDYES' tells MessageBox to automatically choose IDYES if the installer is silent |
14 |
# in this case, the installer can only be silent if the user used the /S switch or if |
15 |
# you've uncommented line number 5 |
16 |
MessageBox MB_YESNO|MB_ICONQUESTION "Would you like the installer to be silent from now on?" \ |
17 |
/SD IDYES IDNO no IDYES yes |
18 |
|
19 |
# SetSilent can only be used in .onInit and doesn't work well along with `SetSilent silent' |
20 |
|
21 |
yes: |
22 |
SetSilent silent |
23 |
Goto done |
24 |
no: |
25 |
SetSilent normal |
26 |
done: |
27 |
FunctionEnd |
28 |
|
29 |
Section |
30 |
IfSilent 0 +2 |
31 |
MessageBox MB_OK|MB_ICONINFORMATION 'This is a "silent" installer' |
32 |
|
33 |
# there is no need to use IfSilent for this one because the /SD switch takes care of that |
34 |
MessageBox MB_OK|MB_ICONINFORMATION "This is not a silent installer" /SD IDOK |
35 |
|
36 |
# when `SetOverwrite on' (which is the default) is used, the installer will show a message |
37 |
# if it can't open a file for writing. On silent installers, the ignore option will be |
38 |
# automatically selected. if `AllowSkipFiles off' (default is on) was used, there is no |
39 |
# ignore option and the cancel option will be automatically selected. |
40 |
|
41 |
# on is default |
42 |
; AllowSkipFiles on |
43 |
|
44 |
# lock file |
45 |
FileOpen $0 $TEMP\silentOverwrite w |
46 |
# try to extract - will fail |
47 |
File /oname=$TEMP\silentOverwrite silent.nsi |
48 |
# unlcok |
49 |
FileClose $0 |
50 |
|
51 |
# this will always show on silent installers because ignore is the option automatically |
52 |
# selected when a file can't be opened for writing on a silent installer |
53 |
MessageBox MB_OK|MB_ICONINFORMATION "This message box always shows if the installer is silent" |
54 |
|
55 |
AllowSkipFiles off |
56 |
|
57 |
# lock file |
58 |
FileOpen $0 $TEMP\silentOverwrite w |
59 |
# try to extract - will fail |
60 |
File /oname=$TEMP\silentOverwrite silent.nsi |
61 |
# unlcok |
62 |
FileClose $0 |
63 |
SectionEnd |