home *** CD-ROM | disk | FTP | other *** search
/ Chip 2004 March / CMCD0304.ISO / Software / Freeware / Programare / nullsoft / nsis20.exe / Examples / silent.nsi < prev    next >
Text File  |  2004-02-06  |  2KB  |  62 lines

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