livetrace/installer/livetrace-installer.nsi
2026-09-09 17:23:01 +03:00

139 lines
5.9 KiB
NSIS
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

; livetrace-installer.nsi
; NSIS installer for livetrace v3.3.2
; Builds on Linux (or in Docker) with: makensis livetrace-installer.nsi
;
; Place livetrace-windows-amd64.exe in the same directory before building.
Unicode True
; ──────────────────────────────────────────────
; Metadata
; ──────────────────────────────────────────────
!define APPNAME "livetrace"
!define APPVERSION "3.3.2"
!define PUBLISHER "ngtech1ltd"
; Source binary name (as built by Go)
!define SRC_EXE "livetrace-windows-amd64.exe"
; Name it will have after installation
!define INST_EXE "livetrace.exe"
; Registry key for Add/Remove Programs
!define REG_UNINSTALL \
"Software\Microsoft\Windows\CurrentVersion\Uninstall\${APPNAME}"
; ──────────────────────────────────────────────
; Installer settings
; ──────────────────────────────────────────────
Name "${APPNAME} ${APPVERSION}"
OutFile "livetrace-${APPVERSION}-setup.exe"
InstallDir "$PROGRAMFILES64\${APPNAME}"
InstallDirRegKey HKLM "${REG_UNINSTALL}" "InstallLocation"
; Administrator rights required (Program Files + system PATH)
RequestExecutionLevel admin
SetCompressor /SOLID lzma
SetCompressorDictSize 32
; ──────────────────────────────────────────────
; UI
; ──────────────────────────────────────────────
!include "MUI2.nsh"
!define MUI_ABORTWARNING
!insertmacro MUI_PAGE_DIRECTORY
!insertmacro MUI_PAGE_INSTFILES
!insertmacro MUI_PAGE_FINISH
!insertmacro MUI_UNPAGE_CONFIRM
!insertmacro MUI_UNPAGE_INSTFILES
!insertmacro MUI_LANGUAGE "English"
; ──────────────────────────────────────────────
; Version info (visible in Properties → Details)
; ──────────────────────────────────────────────
VIProductVersion "3.3.2.0"
VIAddVersionKey "ProductName" "${APPNAME}"
VIAddVersionKey "ProductVersion" "${APPVERSION}"
VIAddVersionKey "CompanyName" "${PUBLISHER}"
VIAddVersionKey "FileDescription" "${APPNAME} Installer"
VIAddVersionKey "FileVersion" "${APPVERSION}"
VIAddVersionKey "LegalCopyright" "(c) ${PUBLISHER}"
; ──────────────────────────────────────────────
; PATH helpers (PowerShell avoids NSIS macro
; namespace issues between install / uninstall)
; ──────────────────────────────────────────────
; Append $INSTDIR to the machine-wide PATH
; Note: $$p / $$parts / $$_ are PowerShell variables — $$ escapes the $ for NSIS
!macro AddToPath
DetailPrint "Adding $INSTDIR to system PATH …"
nsExec::ExecToLog \
'powershell.exe -NonInteractive -NoProfile -Command \
"$$p = [Environment]::GetEnvironmentVariable(\"Path\",\"Machine\"); \
if ($$p -notlike \"*$INSTDIR*\") { \
[Environment]::SetEnvironmentVariable(\"Path\", \"$$p;$INSTDIR\", \"Machine\") \
}"'
!macroend
; Remove $INSTDIR from the machine-wide PATH
!macro RemoveFromPath
DetailPrint "Removing $INSTDIR from system PATH "
nsExec::ExecToLog \
'powershell.exe -NonInteractive -NoProfile -Command \
"$$parts = [Environment]::GetEnvironmentVariable(\"Path\",\"Machine\") -split \";\"; \
$$parts = $$parts | Where-Object { $$_ -ne \"$INSTDIR\" }; \
[Environment]::SetEnvironmentVariable(\"Path\", ($$parts -join \";\"), \"Machine\")"'
!macroend
; ──────────────────────────────────────────────
; Install section
; ──────────────────────────────────────────────
Section "livetrace (required)" SecMain
SectionIn RO ; cannot be deselected
SetOutPath "$INSTDIR"
; Copy binary — rename to plain "livetrace.exe" on the way in
File "/oname=${INST_EXE}" "${SRC_EXE}"
; Add install dir to system PATH
!insertmacro AddToPath
; Register with Add/Remove Programs
WriteRegStr HKLM "${REG_UNINSTALL}" "DisplayName" "${APPNAME} ${APPVERSION}"
WriteRegStr HKLM "${REG_UNINSTALL}" "DisplayVersion" "${APPVERSION}"
WriteRegStr HKLM "${REG_UNINSTALL}" "Publisher" "${PUBLISHER}"
WriteRegStr HKLM "${REG_UNINSTALL}" "InstallLocation" "$INSTDIR"
WriteRegStr HKLM "${REG_UNINSTALL}" "UninstallString" '"$INSTDIR\uninstall.exe"'
WriteRegStr HKLM "${REG_UNINSTALL}" "QuietUninstallString" '"$INSTDIR\uninstall.exe" /S'
WriteRegDWORD HKLM "${REG_UNINSTALL}" "NoModify" 1
WriteRegDWORD HKLM "${REG_UNINSTALL}" "NoRepair" 1
; Write the uninstaller
WriteUninstaller "$INSTDIR\uninstall.exe"
SectionEnd
; ──────────────────────────────────────────────
; Uninstall section
; ──────────────────────────────────────────────
Section "Uninstall"
; Remove from system PATH
!insertmacro RemoveFromPath
; Delete files
Delete "$INSTDIR\${INST_EXE}"
Delete "$INSTDIR\uninstall.exe"
RMDir "$INSTDIR"
; Remove Add/Remove Programs entry
DeleteRegKey HKLM "${REG_UNINSTALL}"
SectionEnd