mirror of
https://github.com/Serial-Studio/Serial-Studio.git
synced 2025-01-15 05:22:53 +08:00
114 lines
4.9 KiB
NSIS
114 lines
4.9 KiB
NSIS
|
;
|
||
|
; Copyright (c) 2015 Alex Spataru <alex-spataru.com>
|
||
|
;
|
||
|
; This program is free software; you can redistribute it and/or modify
|
||
|
; it under the terms of the GNU General Public License as published by
|
||
|
; the Free Software Foundation; either version 3 of the License, or
|
||
|
; (at your option) any later version.
|
||
|
;
|
||
|
; This program is distributed in the hope that it will be useful,
|
||
|
; but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||
|
; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||
|
; GNU General Public License for more details.
|
||
|
;
|
||
|
; You should have received a copy of the GNU General Public License
|
||
|
; along with this program; if not, write to the Free Software
|
||
|
; Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111-1301
|
||
|
; USA
|
||
|
;
|
||
|
|
||
|
!include "MUI2.nsh"
|
||
|
!include "LogicLib.nsh"
|
||
|
|
||
|
!define APPNAME "Serial-Studio"
|
||
|
!define UNIXNAME "serial-studio"
|
||
|
!define COMPANYNAME "Alex Spataru"
|
||
|
!define DESCRIPTION "Open source alternative to the FRC DriverStation"
|
||
|
!define VERSIONMAJOR 1
|
||
|
!define VERSIONMINOR 0
|
||
|
!define VERSIONBUILD 5
|
||
|
!define ESTIMATED_SIZE 60000
|
||
|
!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"
|
||
|
!define MUI_WELCOMEPAGE_TITLE "Welcome to the Serial Studio installer!"
|
||
|
|
||
|
!insertmacro MUI_PAGE_WELCOME
|
||
|
!insertmacro MUI_PAGE_LICENSE "license.txt"
|
||
|
!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
|
||
|
OutFile "${UNIXNAME}-${VERSIONMAJOR}.${VERSIONMINOR}${VERSIONBUILD}-setup.exe"
|
||
|
|
||
|
Function .onInit
|
||
|
setShellVarContext all
|
||
|
!insertmacro VerifyUserIsAdmin
|
||
|
FunctionEnd
|
||
|
|
||
|
Section "${APPNAME} (required)" SecDummy
|
||
|
SectionIn RO
|
||
|
SetOutPath "${INSTALL_DIR}"
|
||
|
File /r "${APPNAME}\*"
|
||
|
DeleteRegKey HKCU "Software\${COMPANYNAME}\${APPNAME}"
|
||
|
DeleteRegKey HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\${COMPANYNAME} ${APPNAME}"
|
||
|
|
||
|
WriteUninstaller "${INSTALL_DIR}\uninstall.exe"
|
||
|
WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\${COMPANYNAME} ${APPNAME}" "DisplayName" "${APPNAME}"
|
||
|
WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\${COMPANYNAME} ${APPNAME}" "UninstallString" "${INSTALL_DIR}\uninstall.exe"
|
||
|
WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\${COMPANYNAME} ${APPNAME}" "InstallLocation" "${INSTALL_DIR}"
|
||
|
WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\${COMPANYNAME} ${APPNAME}" "Publisher" "${COMPANYNAME}"
|
||
|
WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\${COMPANYNAME} ${APPNAME}" "DisplayIcon" "${INSTALL_DIR}\bin\${APPNAME}.exe"
|
||
|
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
|
||
|
WriteRegDWORD HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\${COMPANYNAME} ${APPNAME}" "NoRepair" 1
|
||
|
WriteRegDWORD HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\${COMPANYNAME} ${APPNAME}" "EstimatedSize" ${ESTIMATED_SIZE}
|
||
|
|
||
|
SectionEnd
|
||
|
|
||
|
Section "Start Menu Shortcuts"
|
||
|
CreateShortCut "$SMPROGRAMS\${APPNAME}.lnk" "${INSTALL_DIR}\bin\${APPNAME}.exe" "" "${INSTALL_DIR}\bin\${APPNAME}.exe" 0
|
||
|
SectionEnd
|
||
|
|
||
|
Function RunApplication
|
||
|
ExecShell "" "${INSTALL_DIR}\bin\${APPNAME}.exe"
|
||
|
FunctionEnd
|
||
|
|
||
|
Function un.onInit
|
||
|
SetShellVarContext all
|
||
|
MessageBox MB_OKCANCEL|MB_ICONQUESTION "Are you sure that you want to uninstall ${APPNAME}?" IDOK next
|
||
|
Abort
|
||
|
next:
|
||
|
!insertmacro VerifyUserIsAdmin
|
||
|
FunctionEnd
|
||
|
|
||
|
Section "Uninstall"
|
||
|
RMDir /r "${INSTALL_DIR}"
|
||
|
RMDir /r "$SMPROGRAMS\${APPNAME}.lnk"
|
||
|
DeleteRegKey HKCU "Software\${COMPANYNAME}\${APPNAME}"
|
||
|
DeleteRegKey HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\${COMPANYNAME} ${APPNAME}"
|
||
|
SectionEnd
|