Files
client/native/packaging/windows.nsi
T
omar eb24965076
ci / linux-arm64-cross (push) Successful in 4m7s
ci / linux-x64 (push) Successful in 4m42s
Implement Rust and Slint native client migration and fix desktop startup
2026-11-10 15:45:24 +03:00

77 lines
2.7 KiB
NSIS

Unicode true
!include "MUI2.nsh"
!include "LogicLib.nsh"
!ifndef STAGE
!error "STAGE must name a verified native payload"
!endif
Name "TeamsPeach"
OutFile "${OUTPUT}"
InstallDir "$LOCALAPPDATA\Programs\TeamsPeach"
InstallDirRegKey HKCU "Software\TeamsPeach\Native" "InstallDir"
RequestExecutionLevel user
SetCompressor /SOLID lzma
!define MUI_ICON "${STAGE}\icon.ico"
!insertmacro MUI_PAGE_DIRECTORY
!insertmacro MUI_PAGE_INSTFILES
!insertmacro MUI_UNPAGE_CONFIRM
!insertmacro MUI_UNPAGE_INSTFILES
!insertmacro MUI_LANGUAGE "English"
Var InstallationId
Function .onInit
SetRegView 64
FunctionEnd
Section "TeamsPeach"
SetRegView 64
ReadRegStr $InstallationId HKCU "Software\TeamsPeach\Native" "InstallationId"
${If} $InstallationId == ""
IfFileExists "$INSTDIR\native-installation.json" 0 create_identity
MessageBox MB_ICONSTOP "Existing installation receipt has no matching installation registration. Refusing to replace its identity."
SetErrorLevel 2
Quit
create_identity:
System::Call 'ole32::CoCreateGuid(g .r0) i.r1'
${If} $1 != 0
SetErrorLevel 3
Quit
${EndIf}
StrCpy $InstallationId $0
${EndIf}
SetOutPath "$INSTDIR"
ClearErrors
File /r "${STAGE}\*"
${If} ${Errors}
SetErrorLevel 4
Quit
${EndIf}
FileOpen $0 "$INSTDIR\native-installation.json" w
${If} ${Errors}
SetErrorLevel 5
Quit
${EndIf}
FileWrite $0 '{$\r$\n "schema": 1,$\r$\n "id": "$InstallationId",$\r$\n "target": "${TARGET}",$\r$\n "kind": "nsis",$\r$\n "version": "${VERSION}",$\r$\n "executable": "teamspeach.exe"$\r$\n}$\r$\n'
FileClose $0
${If} ${Errors}
SetErrorLevel 6
Quit
${EndIf}
WriteUninstaller "$INSTDIR\Uninstall.exe"
${If} ${Errors}
SetErrorLevel 7
Quit
${EndIf}
WriteRegStr HKCU "Software\TeamsPeach\Native" "InstallationId" "$InstallationId"
WriteRegStr HKCU "Software\TeamsPeach\Native" "InstallDir" "$INSTDIR"
WriteRegStr HKCU "Software\Microsoft\Windows\CurrentVersion\Uninstall\TeamsPeachNative" "DisplayName" "TeamsPeach Native"
WriteRegStr HKCU "Software\Microsoft\Windows\CurrentVersion\Uninstall\TeamsPeachNative" "DisplayVersion" "${VERSION}"
WriteRegStr HKCU "Software\Microsoft\Windows\CurrentVersion\Uninstall\TeamsPeachNative" "UninstallString" '"$INSTDIR\Uninstall.exe"'
CreateShortcut "$SMPROGRAMS\TeamsPeach.lnk" "$INSTDIR\teamspeach.exe"
SectionEnd
Section "Uninstall"
Delete "$SMPROGRAMS\TeamsPeach.lnk"
; The profile is outside the installation directory and is never touched.
RMDir /r "$INSTDIR"
SetRegView 64
DeleteRegKey HKCU "Software\TeamsPeach\Native"
DeleteRegKey HKCU "Software\Microsoft\Windows\CurrentVersion\Uninstall\TeamsPeachNative"
SectionEnd