2021-01-09 17:30:27 -08:00
|
|
|
;
|
2021-10-08 04:02:12 -05:00
|
|
|
; Copyright (c) 2020-2021 Alex Spataru <https://github.com/alex-spataru>
|
2021-01-09 17:30:27 -08:00
|
|
|
;
|
2021-10-08 04:02:12 -05:00
|
|
|
; Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
|
|
; of this software and associated documentation files (the "Software"), to deal
|
|
|
|
; in the Software without restriction, including without limitation the rights
|
|
|
|
; to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
|
|
; copies of the Software, and to permit persons to whom the Software is
|
|
|
|
; furnished to do so, subject to the following conditions:
|
2021-01-09 17:30:27 -08:00
|
|
|
;
|
2021-10-08 04:02:12 -05:00
|
|
|
; The above copyright notice and this permission notice shall be included in
|
|
|
|
; all copies or substantial portions of the Software.
|
2021-01-09 17:30:27 -08:00
|
|
|
;
|
2021-10-08 04:02:12 -05:00
|
|
|
; THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
|
|
; IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
|
|
; FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
|
|
; AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
|
|
; LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
|
|
; OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
|
|
|
; THE SOFTWARE.
|
2021-01-09 17:30:27 -08:00
|
|
|
;
|
|
|
|
|
2021-01-09 17:34:23 -08:00
|
|
|
Unicode True
|
|
|
|
|
2021-01-09 17:30:27 -08:00
|
|
|
!include "MUI2.nsh"
|
2021-01-13 20:22:59 -05:00
|
|
|
!include "FileFunc.nsh"
|
2021-01-09 17:30:27 -08:00
|
|
|
!include "LogicLib.nsh"
|
|
|
|
|
2021-01-13 14:38:12 -05:00
|
|
|
!define APPNAME "Serial Studio"
|
2021-01-13 16:01:08 -05:00
|
|
|
!define EXECNAME "SerialStudio"
|
2021-01-09 17:30:27 -08:00
|
|
|
!define COMPANYNAME "Alex Spataru"
|
2021-01-13 14:38:12 -05:00
|
|
|
!define DESCRIPTION "Dashboard software for serial port devices"
|
2021-01-09 17:30:27 -08:00
|
|
|
!define VERSIONMAJOR 1
|
2021-10-08 04:02:12 -05:00
|
|
|
!define VERSIONMINOR 1
|
|
|
|
!define VERSIONBUILD 0
|
2021-01-09 17:30:27 -08:00
|
|
|
!define MUI_ABORTWARNING
|
|
|
|
!define INSTALL_DIR "$PROGRAMFILES64\${APPNAME}"
|
|
|
|
!define MUI_FINISHPAGE_RUN
|
|
|
|
!define MUI_FINISHPAGE_RUN_TEXT "Run ${APPNAME}"
|
|
|
|
!define MUI_FINISHPAGE_RUN_FUNCTION "RunApplication"
|
|
|
|
!define MUI_FINISHPAGE_LINK "Visit project website"
|
|
|
|
!define MUI_FINISHPAGE_LINK_LOCATION "http://github.com/serial-studio/serial-studio"
|
2021-01-13 14:38:12 -05:00
|
|
|
!define MUI_WELCOMEPAGE_TITLE "Welcome to the ${APPNAME} installer!"
|
2021-01-09 17:30:27 -08:00
|
|
|
|
|
|
|
!insertmacro MUI_PAGE_WELCOME
|
|
|
|
!insertmacro MUI_PAGE_DIRECTORY
|
|
|
|
!insertmacro MUI_PAGE_INSTFILES
|
|
|
|
!insertmacro MUI_PAGE_FINISH
|
|
|
|
!insertmacro MUI_UNPAGE_WELCOME
|
|
|
|
!insertmacro MUI_UNPAGE_CONFIRM
|
|
|
|
!insertmacro MUI_UNPAGE_INSTFILES
|
|
|
|
!insertmacro MUI_LANGUAGE "English"
|
|
|
|
|
|
|
|
!macro VerifyUserIsAdmin
|
|
|
|
UserInfo::GetAccountType
|
|
|
|
pop $0
|
|
|
|
${If} $0 != "admin"
|
|
|
|
messageBox mb_iconstop "Administrator rights required!"
|
|
|
|
setErrorLevel 740
|
|
|
|
quit
|
|
|
|
${EndIf}
|
|
|
|
!macroend
|
|
|
|
|
|
|
|
Name "${APPNAME}"
|
|
|
|
ManifestDPIAware true
|
|
|
|
InstallDir "${INSTALL_DIR}"
|
|
|
|
RequestExecutionLevel admin
|
2021-01-13 16:01:08 -05:00
|
|
|
OutFile "${EXECNAME}-${VERSIONMAJOR}.${VERSIONMINOR}.${VERSIONBUILD}-Windows.exe"
|
2021-10-08 04:02:12 -05:00
|
|
|
|
2021-01-09 17:30:27 -08:00
|
|
|
Function .onInit
|
2021-10-13 01:46:12 -05:00
|
|
|
setShellVarContext all
|
|
|
|
!insertmacro VerifyUserIsAdmin
|
|
|
|
|
|
|
|
ReadRegStr $R0 HKLM \
|
|
|
|
"Software\Microsoft\Windows\CurrentVersion\Uninstall\${PROGRAM_NAME}" \
|
|
|
|
"UninstallString"
|
|
|
|
StrCmp $R0 "" done
|
|
|
|
|
|
|
|
MessageBox MB_OKCANCEL|MB_ICONEXCLAMATION \
|
|
|
|
"${APPNAME} is already installed. $\n$\nClick `OK` to remove the \
|
|
|
|
previous version or `Cancel` to cancel this upgrade." \
|
|
|
|
IDOK uninst
|
|
|
|
Abort
|
|
|
|
|
|
|
|
uninst:
|
|
|
|
ClearErrors
|
|
|
|
Exec $INSTDIR\uninstall.exe
|
2021-01-09 17:30:27 -08:00
|
|
|
FunctionEnd
|
|
|
|
|
|
|
|
Section "${APPNAME} (required)" SecDummy
|
|
|
|
SectionIn RO
|
2021-10-08 04:02:12 -05:00
|
|
|
SetOutPath "$INSTDIR"
|
2021-01-09 17:30:27 -08:00
|
|
|
File /r "${APPNAME}\*"
|
2021-10-08 04:02:12 -05:00
|
|
|
|
2021-01-13 22:48:43 -05:00
|
|
|
${GetSize} "$INSTDIR" "/S=0K" $0 $1 $2
|
|
|
|
IntFmt $0 "0x%08X" $0
|
2021-10-08 04:02:12 -05:00
|
|
|
|
|
|
|
DeleteRegKey HKCU "Software\${COMPANYNAME}\${APPNAME}"
|
2021-01-09 17:30:27 -08:00
|
|
|
DeleteRegKey HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\${COMPANYNAME} ${APPNAME}"
|
|
|
|
|
2021-10-08 04:02:12 -05:00
|
|
|
WriteUninstaller "$INSTDIR\uninstall.exe"
|
2021-01-13 22:48:43 -05:00
|
|
|
WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\${COMPANYNAME} ${APPNAME}" "DisplayName" "${APPNAME}"
|
2021-10-08 04:02:12 -05:00
|
|
|
WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\${COMPANYNAME} ${APPNAME}" "UninstallString" "$INSTDIR\uninstall.exe"
|
|
|
|
WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\${COMPANYNAME} ${APPNAME}" "InstallLocation" "$INSTDIR"
|
2021-01-13 22:48:43 -05:00
|
|
|
WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\${COMPANYNAME} ${APPNAME}" "Publisher" "${COMPANYNAME}"
|
2021-10-08 04:02:12 -05:00
|
|
|
WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\${COMPANYNAME} ${APPNAME}" "DisplayIcon" "$INSTDIR\icon.ico"
|
2021-01-09 17:30:27 -08:00
|
|
|
WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\${COMPANYNAME} ${APPNAME}" "DisplayVersion" ${VERSIONMAJOR}.${VERSIONMINOR}${VERSIONBUILD}
|
|
|
|
WriteRegDWORD HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\${COMPANYNAME} ${APPNAME}" "VersionMajor" ${VERSIONMAJOR}
|
|
|
|
WriteRegDWORD HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\${COMPANYNAME} ${APPNAME}" "VersionMinor" ${VERSIONMINOR}
|
|
|
|
WriteRegDWORD HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\${COMPANYNAME} ${APPNAME}" "NoModify" 1
|
2021-01-13 21:09:16 -05:00
|
|
|
WriteRegDWORD HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\${COMPANYNAME} ${APPNAME}" "NoRepair" 1
|
2021-01-13 22:48:43 -05:00
|
|
|
WriteRegDWORD HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\${COMPANYNAME} ${APPNAME}" "EstimatedSize" "$0"
|
2021-01-09 17:30:27 -08:00
|
|
|
SectionEnd
|
|
|
|
|
|
|
|
Section "Start Menu Shortcuts"
|
2021-10-08 04:02:12 -05:00
|
|
|
CreateShortCut "$SMPROGRAMS\${APPNAME}.lnk" "$INSTDIR\bin\${EXECNAME}.exe" "" "$INSTDIR\bin\${EXECNAME}.exe" 0
|
2021-01-09 17:30:27 -08:00
|
|
|
SectionEnd
|
|
|
|
|
2021-01-13 22:48:43 -05:00
|
|
|
Section "Install Visual C++ Redistributable"
|
2021-10-08 04:02:12 -05:00
|
|
|
ExecWait "$INSTDIR\bin\vc_redist.x64.exe /quiet /norestart"
|
|
|
|
Delete "$INSTDIR\bin\vc_redist.x64.exe"
|
2021-01-13 22:48:43 -05:00
|
|
|
SectionEnd
|
|
|
|
|
2021-01-09 17:30:27 -08:00
|
|
|
Function RunApplication
|
2021-10-08 04:02:12 -05:00
|
|
|
ExecShell "" "$INSTDIR\bin\${EXECNAME}.exe"
|
2021-01-09 17:30:27 -08:00
|
|
|
FunctionEnd
|
|
|
|
|
|
|
|
Function un.onInit
|
2021-10-08 04:02:12 -05:00
|
|
|
SetShellVarContext all
|
|
|
|
MessageBox MB_OKCANCEL|MB_ICONQUESTION "Are you sure that you want to uninstall ${APPNAME}?" IDOK next
|
|
|
|
Abort
|
|
|
|
next:
|
|
|
|
!insertmacro VerifyUserIsAdmin
|
2021-01-09 17:30:27 -08:00
|
|
|
FunctionEnd
|
|
|
|
|
|
|
|
Section "Uninstall"
|
2021-10-08 04:02:12 -05:00
|
|
|
RMDir /r "$INSTDIR"
|
2021-01-09 17:30:27 -08:00
|
|
|
RMDir /r "$SMPROGRAMS\${APPNAME}.lnk"
|
|
|
|
DeleteRegKey HKCU "Software\${COMPANYNAME}\${APPNAME}"
|
|
|
|
DeleteRegKey HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\${COMPANYNAME} ${APPNAME}"
|
2021-01-13 14:38:12 -05:00
|
|
|
SectionEnd
|