example2.nsi 2.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192
  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 example2.nsi into a directory that the user selects,
  7. ;--------------------------------
  8. ; The name of the installer
  9. Name "Example2"
  10. ; The file to write
  11. OutFile "example2.exe"
  12. ; The default installation directory
  13. InstallDir $PROGRAMFILES\Example2
  14. ; Registry key to check for directory (so if you install again, it will
  15. ; overwrite the old one automatically)
  16. InstallDirRegKey HKLM "Software\NSIS_Example2" "Install_Dir"
  17. ; Request application privileges for Windows Vista
  18. RequestExecutionLevel admin
  19. ;--------------------------------
  20. ; Pages
  21. Page components
  22. Page directory
  23. Page instfiles
  24. UninstPage uninstConfirm
  25. UninstPage instfiles
  26. ;--------------------------------
  27. ; The stuff to install
  28. Section "Example2 (required)"
  29. SectionIn RO
  30. ; Set output path to the installation directory.
  31. SetOutPath $INSTDIR
  32. ; Put file there
  33. File "example2.nsi"
  34. ; Write the installation path into the registry
  35. WriteRegStr HKLM SOFTWARE\NSIS_Example2 "Install_Dir" "$INSTDIR"
  36. ; Write the uninstall keys for Windows
  37. WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\Example2" "DisplayName" "NSIS Example2"
  38. WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\Example2" "UninstallString" '"$INSTDIR\uninstall.exe"'
  39. WriteRegDWORD HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\Example2" "NoModify" 1
  40. WriteRegDWORD HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\Example2" "NoRepair" 1
  41. WriteUninstaller "uninstall.exe"
  42. SectionEnd
  43. ; Optional section (can be disabled by the user)
  44. Section "Start Menu Shortcuts"
  45. CreateDirectory "$SMPROGRAMS\Example2"
  46. CreateShortcut "$SMPROGRAMS\Example2\Uninstall.lnk" "$INSTDIR\uninstall.exe" "" "$INSTDIR\uninstall.exe" 0
  47. CreateShortcut "$SMPROGRAMS\Example2\Example2 (MakeNSISW).lnk" "$INSTDIR\example2.nsi" "" "$INSTDIR\example2.nsi" 0
  48. SectionEnd
  49. ;--------------------------------
  50. ; Uninstaller
  51. Section "Uninstall"
  52. ; Remove registry keys
  53. DeleteRegKey HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\Example2"
  54. DeleteRegKey HKLM SOFTWARE\NSIS_Example2
  55. ; Remove files and uninstaller
  56. Delete $INSTDIR\example2.nsi
  57. Delete $INSTDIR\uninstall.exe
  58. ; Remove shortcuts, if any
  59. Delete "$SMPROGRAMS\Example2\*.*"
  60. ; Remove directories used
  61. RMDir "$SMPROGRAMS\Example2"
  62. RMDir "$INSTDIR"
  63. SectionEnd