2013-03-15 15:30:44 -07:00
;--------------------------------
;Include Modern UI
2016-03-09 10:55:04 -08:00
!include "TextFunc.nsh" ;Needed for the $GetSize fuction. I know, doesn't sound logical, it isn't.
2013-03-15 15:30:44 -07:00
!include "MUI2.nsh"
2016-03-08 10:42:01 -08:00
;--------------------------------
;Variables
!define PRODUCT_NAME "Electrum"
!define PRODUCT_WEB_SITE "https://github.com/spesmilo/electrum"
!define PRODUCT_PUBLISHER "Electrum Technologies GmbH"
!define PRODUCT_UNINST_KEY "Software\Microsoft\Windows\CurrentVersion\Uninstall\${PRODUCT_NAME}"
2013-03-15 15:30:44 -07:00
;--------------------------------
;General
;Name and file
2016-03-08 10:42:01 -08:00
Name "${PRODUCT_NAME}"
2013-03-15 15:30:44 -07:00
OutFile "dist/electrum-setup.exe"
;Default installation folder
2016-03-08 10:42:01 -08:00
InstallDir "$PROGRAMFILES\${PRODUCT_NAME}"
2013-11-12 21:07:33 -08:00
2013-03-15 15:30:44 -07:00
;Get installation folder from registry if available
2016-03-08 10:42:01 -08:00
InstallDirRegKey HKCU "Software\${PRODUCT_NAME}" ""
2013-03-15 15:30:44 -07:00
;Request application privileges for Windows Vista
RequestExecutionLevel admin
2016-03-08 10:42:01 -08:00
;Specifies whether or not the installer will perform a CRC on itself before allowing an install
CRCCheck on
;Sets whether or not the details of the install are shown. Can be 'hide' (the default) to hide the details by default, allowing the user to view them, or 'show' to show them by default, or 'nevershow', to prevent the user from ever seeing them.
ShowInstDetails show
;Sets whether or not the details of the uninstall are shown. Can be 'hide' (the default) to hide the details by default, allowing the user to view them, or 'show' to show them by default, or 'nevershow', to prevent the user from ever seeing them.
ShowUninstDetails show
;Sets the colors to use for the install info screen (the default is 00FF00 000000. Use the form RRGGBB (in hexadecimal, as in HTML, only minus the leading '#', since # can be used for comments). Note that if "/windows" is specified as the only parameter, the default windows colors will be used.
InstallColors /windows
;This command sets the compression algorithm used to compress files/data in the installer. (http://nsis.sourceforge.net/Reference/SetCompressor)
SetCompressor /SOLID lzma
;Sets the dictionary size in megabytes (MB) used by the LZMA compressor (default is 8 MB).
SetCompressorDictSize 64
;Sets the text that is shown (by default it is 'Nullsoft Install System vX.XX') in the bottom of the install window. Setting this to an empty string ("") uses the default; to set the string to blank, use " " (a space).
BrandingText "${PRODUCT_NAME} Installer v${PRODUCT_VERSION}"
;Sets what the titlebars of the installer will display. By default, it is 'Name Setup', where Name is specified with the Name command. You can, however, override it with 'MyApp Installer' or whatever. If you specify an empty string (""), the default will be used (you can however specify " " to achieve a blank string)
Caption "${PRODUCT_NAME}"
;Adds the Product Version on top of the Version Tab in the Properties of the file.
2016-03-09 10:41:54 -08:00
VIProductVersion 1.0.0.0
2016-03-08 10:42:01 -08:00
;VIAddVersionKey - Adds a field in the Version Tab of the File Properties. This can either be a field provided by the system or a user defined field.
VIAddVersionKey ProductName "${PRODUCT_NAME} Installer"
VIAddVersionKey Comments "The installer for ${PRODUCT_NAME}"
VIAddVersionKey CompanyName "${PRODUCT_NAME}"
VIAddVersionKey LegalCopyright "2013-2016 ${PRODUCT_PUBLISHER}"
VIAddVersionKey FileDescription "${PRODUCT_NAME} Installer"
VIAddVersionKey FileVersion ${PRODUCT_VERSION}
VIAddVersionKey ProductVersion ${PRODUCT_VERSION}
VIAddVersionKey InternalName "${PRODUCT_NAME} Installer"
VIAddVersionKey LegalTrademarks "${PRODUCT_NAME} is a trademark of ${PRODUCT_PUBLISHER}"
VIAddVersionKey OriginalFilename "${PRODUCT_NAME}.exe"
2013-03-15 15:30:44 -07:00
;--------------------------------
;Interface Settings
!define MUI_ABORTWARNING
2016-03-08 10:42:01 -08:00
!define MUI_ABORTWARNING_TEXT "Are you sure you wish to abort the installation of ${PRODUCT_NAME}?"
2017-12-10 09:51:03 -08:00
!define MUI_ICON "tmp\electrum\icons\electrum.ico"
2016-03-08 10:42:01 -08:00
2013-03-15 15:30:44 -07:00
;--------------------------------
;Pages
!insertmacro MUI_PAGE_DIRECTORY
!insertmacro MUI_PAGE_INSTFILES
!insertmacro MUI_UNPAGE_CONFIRM
!insertmacro MUI_UNPAGE_INSTFILES
;--------------------------------
;Languages
2013-11-12 21:07:33 -08:00
2013-03-15 15:30:44 -07:00
!insertmacro MUI_LANGUAGE "English"
;--------------------------------
;Installer Sections
2016-03-08 10:42:01 -08:00
;Check if we have Administrator rights
Function .onInit
UserInfo::GetAccountType
pop $0
${If} $0 != "admin" ;Require admin rights on NT4+
MessageBox mb_iconstop "Administrator rights required!"
SetErrorLevel 740 ;ERROR_ELEVATION_REQUIRED
Quit
${EndIf}
FunctionEnd
2013-03-15 15:30:44 -07:00
2016-03-08 10:42:01 -08:00
Section
SetOutPath $INSTDIR
2013-11-12 21:07:33 -08:00
2017-03-26 09:55:25 -07:00
;Uninstall previous version files
RMDir /r "$INSTDIR\*.*"
Delete "$DESKTOP\${PRODUCT_NAME}.lnk"
Delete "$SMPROGRAMS\${PRODUCT_NAME}\*.*"
2016-03-08 10:42:01 -08:00
;Files to pack into the installer
2016-03-09 10:58:43 -08:00
File /r "dist\electrum\*.*"
2016-03-09 10:47:14 -08:00
File "..\..\icons\electrum.ico"
2013-11-12 21:07:33 -08:00
2013-03-15 15:30:44 -07:00
;Store installation folder
2016-03-08 10:42:01 -08:00
WriteRegStr HKCU "Software\${PRODUCT_NAME}" "" $INSTDIR
2013-11-12 21:07:33 -08:00
2013-03-15 15:30:44 -07:00
;Create uninstaller
2016-03-09 10:58:43 -08:00
DetailPrint "Creating uninstaller..."
2013-03-15 15:30:44 -07:00
WriteUninstaller "$INSTDIR\Uninstall.exe"
2016-03-09 10:58:43 -08:00
;Create desktop shortcut
DetailPrint "Creating desktop shortcut..."
2017-03-09 15:40:46 -08:00
CreateShortCut "$DESKTOP\${PRODUCT_NAME}.lnk" "$INSTDIR\electrum-${PRODUCT_VERSION}.exe" ""
2013-03-15 15:30:44 -07:00
2016-03-09 10:58:43 -08:00
;Create start-menu items
DetailPrint "Creating start-menu items..."
2016-03-08 10:42:01 -08:00
CreateDirectory "$SMPROGRAMS\${PRODUCT_NAME}"
CreateShortCut "$SMPROGRAMS\${PRODUCT_NAME}\Uninstall.lnk" "$INSTDIR\Uninstall.exe" "" "$INSTDIR\Uninstall.exe" 0
2017-03-09 15:40:46 -08:00
CreateShortCut "$SMPROGRAMS\${PRODUCT_NAME}\${PRODUCT_NAME}.lnk" "$INSTDIR\electrum-${PRODUCT_VERSION}.exe" "" "$INSTDIR\electrum-${PRODUCT_VERSION}.exe" 0
2017-12-10 10:10:26 -08:00
CreateShortCut "$SMPROGRAMS\${PRODUCT_NAME}\${PRODUCT_NAME} Testnet.lnk" "$INSTDIR\electrum-${PRODUCT_VERSION}.exe" "--testnet" "$INSTDIR\electrum-${PRODUCT_VERSION}.exe" 0
2016-03-08 10:42:01 -08:00
;Links bitcoin: URI's to Electrum
WriteRegStr HKCU "Software\Classes\bitcoin" "" "URL:bitcoin Protocol"
WriteRegStr HKCU "Software\Classes\bitcoin" "URL Protocol" ""
WriteRegStr HKCU "Software\Classes\bitcoin" "DefaultIcon" "$\"$INSTDIR\electrum.ico, 0$\""
2017-03-09 15:40:46 -08:00
WriteRegStr HKCU "Software\Classes\bitcoin\shell\open\command" "" "$\"$INSTDIR\electrum-${PRODUCT_VERSION}.exe$\" $\"%1$\""
2016-03-08 10:42:01 -08:00
;Adds an uninstaller possibilty to Windows Uninstall or change a program section
WriteRegStr HKCU "${PRODUCT_UNINST_KEY}" "DisplayName" "$(^Name)"
WriteRegStr HKCU "${PRODUCT_UNINST_KEY}" "UninstallString" "$INSTDIR\Uninstall.exe"
WriteRegStr HKCU "${PRODUCT_UNINST_KEY}" "DisplayVersion" "${PRODUCT_VERSION}"
WriteRegStr HKCU "${PRODUCT_UNINST_KEY}" "URLInfoAbout" "${PRODUCT_WEB_SITE}"
WriteRegStr HKCU "${PRODUCT_UNINST_KEY}" "Publisher" "${PRODUCT_PUBLISHER}"
2016-03-09 10:55:04 -08:00
WriteRegStr HKCU "${PRODUCT_UNINST_KEY}" "DisplayIcon" "$INSTDIR\electrum.ico"
2016-03-08 10:42:01 -08:00
;Fixes Windows broken size estimates
2016-03-09 10:55:04 -08:00
${GetSize} "$INSTDIR" "/S=0K" $0 $1 $2
IntFmt $0 "0x%08X" $0
WriteRegDWORD HKCU "${PRODUCT_UNINST_KEY}" "EstimatedSize" "$0"
2013-03-15 15:30:44 -07:00
SectionEnd
;--------------------------------
;Descriptions
;--------------------------------
;Uninstaller Section
Section "Uninstall"
RMDir /r "$INSTDIR\*.*"
RMDir "$INSTDIR"
2013-11-12 21:07:33 -08:00
2016-03-08 10:42:01 -08:00
Delete "$DESKTOP\${PRODUCT_NAME}.lnk"
Delete "$SMPROGRAMS\${PRODUCT_NAME}\*.*"
RMDir "$SMPROGRAMS\${PRODUCT_NAME}"
DeleteRegKey HKCU "Software\Classes\bitcoin"
DeleteRegKey HKCU "Software\${PRODUCT_NAME}"
DeleteRegKey HKCU "${PRODUCT_UNINST_KEY}"
2017-12-10 09:51:03 -08:00
SectionEnd