2 ;Copyright (C) 2012 Pulse-Eight Ltd.
3 ;http://www.pulse-eight.com/
6 !include "nsDialogs.nsh"
7 !include "LogicLib.nsh"
10 Name "Pulse-Eight libCEC version 2.0.0"
11 OutFile "..\build\libCEC-installer.exe"
14 InstallDir "$PROGRAMFILES\Pulse-Eight\USB-CEC Adapter"
15 InstallDirRegKey HKLM "Software\Pulse-Eight\USB-CEC Adapter software" ""
16 RequestExecutionLevel admin
18 Var VSRedistSetupError
21 !define MUI_FINISHPAGE_LINK "Visit http://www.pulse-eight.com/ for more information."
22 !define MUI_FINISHPAGE_LINK_LOCATION "http://www.pulse-eight.com/"
23 !define MUI_ABORTWARNING
25 !insertmacro MUI_PAGE_WELCOME
26 !insertmacro MUI_PAGE_LICENSE "..\COPYING"
27 !insertmacro MUI_PAGE_COMPONENTS
28 !insertmacro MUI_PAGE_DIRECTORY
30 !define MUI_STARTMENUPAGE_REGISTRY_ROOT "HKLM"
31 !define MUI_STARTMENUPAGE_REGISTRY_KEY "Software\Pulse-Eight\USB-CEC Adapter sofware"
32 !define MUI_STARTMENUPAGE_REGISTRY_VALUENAME "Start Menu Folder"
33 !insertmacro MUI_PAGE_STARTMENU Application $StartMenuFolder
35 !insertmacro MUI_PAGE_INSTFILES
36 !insertmacro MUI_PAGE_FINISH
38 !insertmacro MUI_UNPAGE_WELCOME
39 !insertmacro MUI_UNPAGE_CONFIRM
40 !insertmacro MUI_UNPAGE_INSTFILES
41 !insertmacro MUI_UNPAGE_FINISH
43 !insertmacro MUI_LANGUAGE "English"
45 InstType "USB-CEC driver & libCEC"
46 InstType "USB-CEC driver only"
47 InstType "Full installation"
49 Section "USB-CEC driver" SecDriver
50 SetShellVarContext current
54 ; Uninstall the old unsigned software if it's found
55 ReadRegStr $1 HKCU "Software\libCEC" ""
58 "A previous libCEC and USB-CEC driver was found. This update requires the old version to be uninstalled. Press OK to uninstall the old version."
59 ExecWait '"$1\Uninstall.exe" /S _?=$1'
60 Delete "$1\Uninstall.exe"
64 ; Delete libcec.dll and libcec.x64.dll from the system directory
65 ; Let a seperate installer do this, when we need it
66 Delete "$SYSDIR\libcec.dll"
68 Delete "$SYSDIR\libcec.x64.dll"
71 ; Copy to the installation directory
76 ; Copy the driver installer
77 SetOutPath "$INSTDIR\driver"
78 File "..\build\p8-usbcec-driver-installer.exe"
80 ;Store installation folder
81 WriteRegStr HKLM "Software\Pulse-Eight\USB-CEC Adapter software" "" $INSTDIR
84 WriteUninstaller "$INSTDIR\Uninstall.exe"
86 !insertmacro MUI_STARTMENU_WRITE_BEGIN Application
89 CreateDirectory "$SMPROGRAMS\$StartMenuFolder"
90 CreateShortCut "$SMPROGRAMS\$StartMenuFolder\Uninstall Pulse-Eight USB-CEC Adapter software.lnk" "$INSTDIR\Uninstall.exe" \
91 "" "$INSTDIR\Uninstall.exe" 0 SW_SHOWNORMAL \
92 "" "Uninstall Pulse-Eight USB-CEC Adapter software."
94 WriteINIStr "$SMPROGRAMS\$StartMenuFolder\Visit Pulse-Eight.url" "InternetShortcut" "URL" "http://www.pulse-eight.com/"
95 !insertmacro MUI_STARTMENU_WRITE_END
97 ;add entry to add/remove programs
98 WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\Pulse-Eight USB-CEC Adapter sofware" \
99 "DisplayName" "Pulse-Eight USB-CEC Adapter software"
100 WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\Pulse-Eight USB-CEC Adapter sofware" \
101 "UninstallString" "$INSTDIR\uninstall.exe"
102 WriteRegDWORD HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\Pulse-Eight USB-CEC Adapter sofware" \
104 WriteRegDWORD HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\Pulse-Eight USB-CEC Adapter sofware" \
106 WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\Pulse-Eight USB-CEC Adapter sofware" \
107 "InstallLocation" "$INSTDIR"
108 WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\Pulse-Eight USB-CEC Adapter sofware" \
109 "DisplayIcon" "$INSTDIR\cec-client.exe,0"
110 WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\Pulse-Eight USB-CEC Adapter sofware" \
111 "Publisher" "Pulse-Eight Limited"
112 WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\Pulse-Eight USB-CEC Adapter sofware" \
113 "HelpLink" "http://www.pulse-eight.com/"
114 WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\Pulse-Eight USB-CEC Adapter sofware" \
115 "URLInfoAbout" "http://www.pulse-eight.com"
118 ExecWait '"$INSTDIR\driver\p8-usbcec-driver-installer.exe" /S'
119 Delete "$INSTDIR\driver\p8-usbcec-driver-installer.exe"
122 Section "libCEC" SecLibCec
123 SetShellVarContext current
126 ; Copy to the installation directory
127 SetOutPath "$INSTDIR"
130 File "..\build\*.dll"
131 File "..\build\*.xml"
132 SetOutPath "$INSTDIR\x64"
133 File /nonfatal "..\build\x64\*.dll"
134 File /nonfatal "..\build\x64\*.xml"
136 ; Copy to XBMC\system
137 ReadRegStr $1 HKCU "Software\XBMC" ""
139 SetOutPath "$1\system"
140 File "..\build\libcec.dll"
144 SetOutPath "$INSTDIR\include"
145 File /r /x *.so "..\include\cec*.*"
148 Section "CEC debug client" SecCecClient
149 SetShellVarContext current
152 ; Copy to the installation directory
153 SetOutPath "$INSTDIR"
154 File /x p8-usbcec-driver-installer.exe /x cec-tray.exe "..\build\*.exe"
155 SetOutPath "$INSTDIR\x64"
156 File /nonfatal /x cec-tray.exe "..\build\x64\*.exe"
158 !insertmacro MUI_STARTMENU_WRITE_BEGIN Application
159 SetOutPath "$INSTDIR"
161 CreateDirectory "$SMPROGRAMS\$StartMenuFolder"
163 CreateShortCut "$SMPROGRAMS\$StartMenuFolder\CEC Test client (x64).lnk" "$INSTDIR\x64\cec-client.x64.exe" \
164 "" "$INSTDIR\cec-client.x64.exe" 0 SW_SHOWNORMAL \
165 "" "Start the CEC Test client (x64)."
167 CreateShortCut "$SMPROGRAMS\$StartMenuFolder\CEC Test client.lnk" "$INSTDIR\cec-client.exe" \
168 "" "$INSTDIR\cec-client.exe" 0 SW_SHOWNORMAL \
169 "" "Start the CEC Test client."
171 !insertmacro MUI_STARTMENU_WRITE_END
175 Section "libCEC Tray" SecCecConfig
176 SetShellVarContext current
179 ; Copy to the installation directory
180 SetOutPath "$INSTDIR"
181 File "..\build\cec-tray.exe"
182 SetOutPath "$INSTDIR\x64"
183 File /nonfatal "..\build\x64\cec-tray.exe"
185 !insertmacro MUI_STARTMENU_WRITE_BEGIN Application
186 SetOutPath "$INSTDIR"
188 CreateDirectory "$SMPROGRAMS\$StartMenuFolder"
190 CreateShortCut "$SMPROGRAMS\$StartMenuFolder\libCEC Tray (x64).lnk" "$INSTDIR\x64\cec-tray.exe" \
191 "" "$INSTDIR\x64\cec-tray.exe" 0 SW_SHOWNORMAL \
192 "" "Start the libCEC Tray (x64)."
194 CreateShortCut "$SMPROGRAMS\$StartMenuFolder\libCEC Tray.lnk" "$INSTDIR\cec-tray.exe" \
195 "" "$INSTDIR\cec-tray.exe" 0 SW_SHOWNORMAL \
196 "" "Start the libCEC Tray."
198 !insertmacro MUI_STARTMENU_WRITE_END
202 !define REDISTRIBUTABLE_SECTIONNAME "Microsoft Visual C++ 2010 Redistributable Package"
203 Section "" SecVCRedist
204 SetShellVarContext current
208 ${If} $VSRedistInstalled != "Yes"
209 ; Download redistributable
210 SetOutPath "$TEMP\vc20XX"
212 NSISdl::download http://packages.pulse-eight.net/windows/vcredist_x64.exe vcredist_x64.exe
213 ExecWait '"$TEMP\vc20XX\vcredist_x64.exe" /q' $VSRedistSetupError
215 NSISdl::download http://packages.pulse-eight.net/windows/vcredist_x86.exe vcredist_x86.exe
216 ExecWait '"$TEMP\vc20XX\vcredist_x86.exe" /q' $VSRedistSetupError
218 RMDIR /r "$TEMP\vc20XX"
226 ReadRegDword $1 HKLM "SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\{196BB40D-1578-3D01-B289-BEFC77A11A1E}" "Version"
228 StrCpy $VSRedistInstalled "Yes"
232 ReadRegDword $1 HKLM "SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\{DA5E371C-6333-3D8A-93A4-6FD5B20BCC6E}" "Version"
234 StrCpy $VSRedistInstalled "Yes"
238 ReadRegDword $1 HKLM "SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\{C1A35166-4301-38E9-BA67-02823AD72A1B}" "Version"
240 StrCpy $VSRedistInstalled "Yes"
244 ReadRegDword $1 HKLM "SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\{F0C3E5D1-1ADE-321E-8167-68EF0DE699A5}" "Version"
246 StrCpy $VSRedistInstalled "Yes"
250 ReadRegDword $1 HKLM "SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\{1D8E6291-B0D5-35EC-8441-6616F567A0F7}" "Version"
252 StrCpy $VSRedistInstalled "Yes"
256 ReadRegDword $1 HKLM "SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\{88C73C1C-2DE5-3B01-AFB8-B46EF4AB41CD}" "Version"
258 StrCpy $VSRedistInstalled "Yes"
261 ${If} $VSRedistInstalled == "Yes"
262 !insertMacro UnSelectSection ${SecVCRedist}
263 SectionSetText ${SecVCRedist} ""
265 !insertMacro SelectSection ${SecVCRedist}
266 SectionSetText ${SecVCRedist} "${REDISTRIBUTABLE_SECTIONNAME}"
271 ;--------------------------------
276 SetShellVarContext current
278 Delete "$INSTDIR\AUTHORS"
279 Delete "$INSTDIR\*.exe"
280 Delete "$INSTDIR\ChangeLog"
281 Delete "$INSTDIR\COPYING"
282 Delete "$INSTDIR\*.dll"
283 Delete "$INSTDIR\*.lib"
284 Delete "$INSTDIR\*.xml"
285 Delete "$INSTDIR\x64\*.dll"
286 Delete "$INSTDIR\x64\*.lib"
287 Delete "$INSTDIR\x64\*.exe"
288 Delete "$INSTDIR\x64\*.xml"
289 Delete "$INSTDIR\README"
290 Delete "$SYSDIR\libcec.dll"
292 Delete "$SYSDIR\libcec.x64.dll"
295 ; Uninstall the driver
296 ReadRegStr $1 HKLM "Software\Pulse-Eight\USB-CEC Adapter driver" ""
298 ExecWait '"$1\Uninstall.exe" /S _?=$1'
301 RMDir /r "$INSTDIR\include"
302 Delete "$INSTDIR\Uninstall.exe"
304 RMDir "$PROGRAMFILES\Pulse-Eight"
306 !insertmacro MUI_STARTMENU_GETFOLDER Application $StartMenuFolder
307 Delete "$SMPROGRAMS\$StartMenuFolder\libCEC Tray.lnk"
309 Delete "$SMPROGRAMS\$StartMenuFolder\libCEC Tray (x64).lnk"
311 Delete "$SMPROGRAMS\$StartMenuFolder\CEC Test client.lnk"
313 Delete "$SMPROGRAMS\$StartMenuFolder\CEC Test client (x64).lnk"
315 Delete "$SMPROGRAMS\$StartMenuFolder\Uninstall Pulse-Eight USB-CEC Adapter software.lnk"
316 Delete "$SMPROGRAMS\$StartMenuFolder\Visit Pulse-Eight.url"
317 RMDir "$SMPROGRAMS\$StartMenuFolder"
319 DeleteRegKey HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\Pulse-Eight USB-CEC Adapter sofware"
320 DeleteRegKey HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\Pulse-Eight USB-CEC Adapter driver"
321 DeleteRegKey /ifempty HKLM "Software\Pulse-Eight\USB-CEC Adapter software"
322 DeleteRegKey /ifempty HKLM "Software\Pulse-Eight"