home *** CD-ROM | disk | FTP | other *** search
/ Chip 2004 March / CMCD0304.ISO / Software / Freeware / Programare / nullsoft / nsis20.exe / Examples / example2.nsi < prev    next >
Text File  |  2003-12-02  |  3KB  |  89 lines

  1. ; example2.nsi
  2. ;
  3. ; This script is based on example1.nsi, but it remember the directory, 
  4. ; has uninstall support and (optionally) installs start menu shortcuts.
  5. ;
  6. ; It will install makensisw.exe into a directory that the user selects,
  7.  
  8. ;--------------------------------
  9.  
  10. ; The name of the installer
  11. Name "Example2"
  12.  
  13. ; The file to write
  14. OutFile "example2.exe"
  15.  
  16. ; The default installation directory
  17. InstallDir $PROGRAMFILES\Example2
  18.  
  19. ; Registry key to check for directory (so if you install again, it will 
  20. ; overwrite the old one automatically)
  21. InstallDirRegKey HKLM "Software\NSIS_Example2" "Install_Dir"
  22.  
  23. ;--------------------------------
  24.  
  25. ; Pages
  26.  
  27. Page components
  28. Page directory
  29. Page instfiles
  30.  
  31. UninstPage uninstConfirm
  32. UninstPage instfiles
  33.  
  34. ;--------------------------------
  35.  
  36. ; The stuff to install
  37. Section "Example2 (required)"
  38.  
  39.   SectionIn RO
  40.   
  41.   ; Set output path to the installation directory.
  42.   SetOutPath $INSTDIR
  43.   
  44.   ; Put file there
  45.   File "..\makensisw.exe"
  46.   
  47.   ; Write the installation path into the registry
  48.   WriteRegStr HKLM SOFTWARE\NSIS_Example2 "Install_Dir" "$INSTDIR"
  49.   
  50.   ; Write the uninstall keys for Windows
  51.   WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\Example2" "DisplayName" "NSIS Example2"
  52.   WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\Example2" "UninstallString" '"$INSTDIR\uninstall.exe"'
  53.   WriteRegDWORD HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\Example2" "NoModify" 1
  54.   WriteRegDWORD HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\Example2" "NoRepair" 1
  55.   WriteUninstaller "uninstall.exe"
  56.   
  57. SectionEnd
  58.  
  59. ; Optional section (can be disabled by the user)
  60. Section "Start Menu Shortcuts"
  61.  
  62.   CreateDirectory "$SMPROGRAMS\Example2"
  63.   CreateShortCut "$SMPROGRAMS\Example2\Uninstall.lnk" "$INSTDIR\uninstall.exe" "" "$INSTDIR\uninstall.exe" 0
  64.   CreateShortCut "$SMPROGRAMS\Example2\Example2 (MakeNSISW).lnk" "$INSTDIR\makensisw.exe" "" "$INSTDIR\makensisw.exe" 0
  65.   
  66. SectionEnd
  67.  
  68. ;--------------------------------
  69.  
  70. ; Uninstaller
  71.  
  72. Section "Uninstall"
  73.   
  74.   ; Remove registry keys
  75.   DeleteRegKey HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\Example2"
  76.   DeleteRegKey HKLM SOFTWARE\NSIS_Example2
  77.  
  78.   ; Remove files and uninstaller
  79.   Delete $INSTDIR\makensisw.exe
  80.   Delete $INSTDIR\uninstall.exe
  81.  
  82.   ; Remove shortcuts, if any
  83.   Delete "$SMPROGRAMS\Example2\*.*"
  84.  
  85.   ; Remove directories used
  86.   RMDir "$SMPROGRAMS\Example2"
  87.   RMDir "$INSTDIR"
  88.  
  89. SectionEnd