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