| 1 |
|
|---|
| 2 | !include "MUI.nsh"
|
|---|
| 3 |
|
|---|
| 4 | !define VERSION "0.2.7"
|
|---|
| 5 |
|
|---|
| 6 | Name "NSClient++ ${VERSION}"
|
|---|
| 7 | OutFile "NSClient++-${VERSION}.exe"
|
|---|
| 8 | InstallDir "$PROGRAMFILES\NSClient++"
|
|---|
| 9 |
|
|---|
| 10 | SetCompressor /SOLID lzma
|
|---|
| 11 |
|
|---|
| 12 | !define MUI_HEADERIMAGE
|
|---|
| 13 | !define MUI_HEADERIMAGE_BITMAP "${NSISDIR}\Contrib\Graphics\Header\win.bmp"
|
|---|
| 14 | !define MUI_ABORTWARNING
|
|---|
| 15 |
|
|---|
| 16 | !insertmacro MUI_PAGE_WELCOME
|
|---|
| 17 | !insertmacro MUI_PAGE_LICENSE license.txt
|
|---|
| 18 | !insertmacro MUI_PAGE_DIRECTORY
|
|---|
| 19 | !insertmacro MUI_PAGE_INSTFILES
|
|---|
| 20 | !insertmacro MUI_UNPAGE_WELCOME
|
|---|
| 21 | !insertmacro MUI_UNPAGE_CONFIRM
|
|---|
| 22 | !insertmacro MUI_UNPAGE_INSTFILES
|
|---|
| 23 | !insertmacro MUI_UNPAGE_FINISH
|
|---|
| 24 |
|
|---|
| 25 | !insertmacro MUI_LANGUAGE "English"
|
|---|
| 26 |
|
|---|
| 27 | Section "Install"
|
|---|
| 28 | SetOutPath "$INSTDIR"
|
|---|
| 29 | File "NSClient++.exe"
|
|---|
| 30 | File "NSC.ini"
|
|---|
| 31 | File "license.txt"
|
|---|
| 32 | File "counters.defs"
|
|---|
| 33 | File "changelog"
|
|---|
| 34 | SetOutPath "$INSTDIR\modules"
|
|---|
| 35 | File "modules\CheckDisk.dll"
|
|---|
| 36 | File "modules\CheckEventLog.dll"
|
|---|
| 37 | File "modules\CheckHelpers.dll"
|
|---|
| 38 | File "modules\CheckSystem.dll"
|
|---|
| 39 | File "modules\CheckWMI.dll"
|
|---|
| 40 | File "modules\FileLogger.dll"
|
|---|
| 41 | File "modules\NRPEListener.dll"
|
|---|
| 42 | File "modules\NSClientListener.dll"
|
|---|
| 43 | File "modules\RemoteConfiguration.dll"
|
|---|
| 44 | File "modules\SysTray.dll"
|
|---|
| 45 | SetOutPath "$INSTDIR\scripts"
|
|---|
| 46 | File "scripts\args.bat"
|
|---|
| 47 | File "scripts\critical.bat"
|
|---|
| 48 | File "scripts\ok.bat"
|
|---|
| 49 |
|
|---|
| 50 | CreateDirectory "$SMPROGRAMS\NSClient++"
|
|---|
| 51 | CreateShortCut "$SMPROGRAMS\NSClient++\Uninstall.lnk" "$INSTDIR\Uninst.exe" "" "$INSTDIR\Uninst.exe" 0
|
|---|
| 52 | CreateShortCut "$SMPROGRAMS\NSClient++\Edit Config.lnk" "notepad.exe" "$INSTDIR\NSC.ini"
|
|---|
| 53 |
|
|---|
| 54 | WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\NSClient++" "DisplayName" "NSClient++ ${VERSION}"
|
|---|
| 55 | WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\NSClient++" "UninstallString" "$INSTDIR\Uninst.exe"
|
|---|
| 56 |
|
|---|
| 57 | ExecWait '"$INSTDIR\NSClient++.exe" /install'
|
|---|
| 58 | ExecWait '"$INSTDIR\NSClient++.exe" /start'
|
|---|
| 59 |
|
|---|
| 60 | WriteUninstaller $INSTDIR\Uninst.exe
|
|---|
| 61 | SectionEnd
|
|---|
| 62 |
|
|---|
| 63 | Section "Uninstall"
|
|---|
| 64 |
|
|---|
| 65 | ExecWait '"$INSTDIR\NSClient++.exe" /stop'
|
|---|
| 66 | ExecWait '"$INSTDIR\NSClient++.exe" /uninstall'
|
|---|
| 67 |
|
|---|
| 68 | DeleteRegKey HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\NSClient++"
|
|---|
| 69 |
|
|---|
| 70 | RMDir /r "$SMPROGRAMS\NSClient++"
|
|---|
| 71 | RMDir /r "$INSTDIR\modules"
|
|---|
| 72 | Delete "$INSTDIR\NSClient++.exe"
|
|---|
| 73 | Delete "$INSTDIR\license.txt"
|
|---|
| 74 | Delete "$INSTDIR\counters.defs"
|
|---|
| 75 | Delete "$INSTDIR\changelog"
|
|---|
| 76 | SectionEnd
|
|---|
| 77 |
|
|---|
| 78 | Function .onInit
|
|---|
| 79 |
|
|---|
| 80 | ReadRegStr $R0 HKLM \
|
|---|
| 81 | "Software\Microsoft\Windows\CurrentVersion\Uninstall\NSClient++" \
|
|---|
| 82 | "UninstallString"
|
|---|
| 83 | StrCmp $R0 "" done
|
|---|
| 84 |
|
|---|
| 85 | MessageBox MB_OKCANCEL|MB_ICONEXCLAMATION \
|
|---|
| 86 | "NSClient++ is already installed. $\n$\nClick `OK` to remove the \
|
|---|
| 87 | previous version or `Cancel` to cancel this upgrade." \
|
|---|
| 88 | IDOK uninst
|
|---|
| 89 | Abort
|
|---|
| 90 |
|
|---|
| 91 | ;Run the uninstaller
|
|---|
| 92 | uninst:
|
|---|
| 93 | ClearErrors
|
|---|
| 94 | ; Copy the uninstaller to a temp location
|
|---|
| 95 | GetTempFileName $0
|
|---|
| 96 | CopyFiles $R0 $0
|
|---|
| 97 | ;Start the uninstaller using the option to not copy itself
|
|---|
| 98 | ExecWait '$0 _?=$INSTDIR'
|
|---|
| 99 |
|
|---|
| 100 | IfErrors no_remove_uninstaller
|
|---|
| 101 | ; In most cases the uninstall is successful at this point.
|
|---|
| 102 | ; You may also consider using a registry key to check whether
|
|---|
| 103 | ; the user has chosen to uninstall. If you are using an uninstaller
|
|---|
| 104 | ; components page, make sure all sections are uninstalled.
|
|---|
| 105 | goto done
|
|---|
| 106 | no_remove_uninstaller:
|
|---|
| 107 | MessageBox MB_ICONEXCLAMATION \
|
|---|
| 108 | "Unable to remove previous version of NSClient++"
|
|---|
| 109 | Abort
|
|---|
| 110 |
|
|---|
| 111 | done:
|
|---|
| 112 | ; remove the copied uninstaller
|
|---|
| 113 | Delete '$0'
|
|---|
| 114 |
|
|---|
| 115 | FunctionEnd
|
|---|
| 116 |
|
|---|