example2.nsi 2.6 KB

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