build: improve nsis script

This commit is contained in:
parhelia512 2025-07-20 09:00:29 +08:00
parent 4ca2e6f6dc
commit 4540f1ce86

View File

@ -1,7 +1,7 @@
Name "Throne" Name "Throne"
OutFile "ThroneSetup.exe" OutFile "ThroneSetup.exe"
InstallDir $APPDATA\Throne InstallDir $APPDATA\Throne
RequestExecutionLevel admin RequestExecutionLevel user
!include MUI2.nsh !include MUI2.nsh
!define MUI_ICON "res\Throne.ico" !define MUI_ICON "res\Throne.ico"
@ -10,8 +10,7 @@ RequestExecutionLevel admin
!define MUI_WELCOMEPAGE_TEXT "This wizard will guide you through the installation of Throne." !define MUI_WELCOMEPAGE_TEXT "This wizard will guide you through the installation of Throne."
!define MUI_FINISHPAGE_RUN "$INSTDIR\Throne.exe" !define MUI_FINISHPAGE_RUN "$INSTDIR\Throne.exe"
!define MUI_FINISHPAGE_RUN_TEXT "Launch Throne" !define MUI_FINISHPAGE_RUN_TEXT "Launch Throne"
!define stopCommand 'powershell -ExecutionPolicy Bypass -WindowStyle Hidden -command "&{Stop-Process -Id (Get-CimInstance -ClassName Win32_Process -Filter $\'Name = $\'$\'Throne.exe$\'$\'$\' | Where-Object { $$_.ExecutablePath -eq $\'$INSTDIR\Throne.exe$\' }).ProcessId -Force}"' !addplugindir .\
!insertmacro MUI_PAGE_WELCOME !insertmacro MUI_PAGE_WELCOME
!insertmacro MUI_PAGE_DIRECTORY !insertmacro MUI_PAGE_DIRECTORY
@ -25,8 +24,9 @@ UninstallIcon "res\ThroneDel.ico"
Section "Install" Section "Install"
SetOutPath "$INSTDIR" SetOutPath "$INSTDIR"
SetOverwrite on
ExecWait '${stopCommand}' FindProcDLL::KillProc "$INSTDIR\Throne.exe"
File /r ".\deployment\windows64\*" File /r ".\deployment\windows64\*"
@ -36,17 +36,17 @@ Section "Install"
CreateShortcut "$SMPROGRAMS\Throne\Throne.lnk" "$INSTDIR\Throne.exe" "" "$INSTDIR\Throne.exe" 0 CreateShortcut "$SMPROGRAMS\Throne\Throne.lnk" "$INSTDIR\Throne.exe" "" "$INSTDIR\Throne.exe" 0
CreateShortcut "$SMPROGRAMS\Throne\Uninstall Throne.lnk" "$INSTDIR\uninstall.exe" CreateShortcut "$SMPROGRAMS\Throne\Uninstall Throne.lnk" "$INSTDIR\uninstall.exe"
WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\Throne" "DisplayName" "Throne" WriteRegStr HKCU "Software\Microsoft\Windows\CurrentVersion\Uninstall\Throne" "DisplayName" "Throne"
WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\Throne" "UninstallString" "$INSTDIR\uninstall.exe" WriteRegStr HKCU "Software\Microsoft\Windows\CurrentVersion\Uninstall\Throne" "UninstallString" "$INSTDIR\uninstall.exe"
WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\Throne" "InstallLocation" "$INSTDIR" WriteRegStr HKCU "Software\Microsoft\Windows\CurrentVersion\Uninstall\Throne" "InstallLocation" "$INSTDIR"
WriteRegDWORD HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\Throne" "NoModify" 1 WriteRegDWORD HKCU "Software\Microsoft\Windows\CurrentVersion\Uninstall\Throne" "NoModify" 1
WriteRegDWORD HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\Throne" "NoRepair" 1 WriteRegDWORD HKCU "Software\Microsoft\Windows\CurrentVersion\Uninstall\Throne" "NoRepair" 1
WriteUninstaller "uninstall.exe" WriteUninstaller "uninstall.exe"
SectionEnd SectionEnd
Section "Uninstall" Section "Uninstall"
ExecWait '${stopCommand}' FindProcDLL::KillProc "$INSTDIR\Throne.exe"
Delete "$SMPROGRAMS\Throne\Throne.lnk" Delete "$SMPROGRAMS\Throne\Throne.lnk"
Delete "$SMPROGRAMS\Throne\Uninstall Throne.lnk" Delete "$SMPROGRAMS\Throne\Uninstall Throne.lnk"
@ -57,5 +57,5 @@ Section "Uninstall"
Delete "$INSTDIR\uninstall.exe" Delete "$INSTDIR\uninstall.exe"
DeleteRegKey HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\Throne" DeleteRegKey HKCU "Software\Microsoft\Windows\CurrentVersion\Uninstall\Throne"
SectionEnd SectionEnd