[desktop] Improve NSIS migration installer

This commit is contained in:
Vladimir Stoilov 2025-03-04 18:08:17 +02:00
parent 0200404eac
commit 161b75e39e
No known key found for this signature in database

View file

@ -6,7 +6,6 @@ var oldInstallationDir
var dataDir
!macro NSIS_HOOK_PREINSTALL
; Abort if old service is running
SimpleSC::ServiceIsStopped "PortmasterCore"
Pop $0
@ -65,12 +64,14 @@ var dataDir
SimpleSC::InstallService "PortmasterCore" "Portmaster Core" "16" "2" "$INSTDIR\portmaster-core.exe --log-dir=%PROGRAMDATA%\Portmaster\logs" "" "" ""
Pop $0 ; returns error code (0 on success)
${If} $0 != 0
SimpleSC::GetErrorMessage $installErr
SimpleSC::GetErrorMessage $0
Pop $0
MessageBox MB_OK "Service creation failed. Error: $errorMsg"
MessageBox MB_OK "Service creation failed. Error: $0"
Abort
${EndIf}
SimpleSC::SetServiceDescription "PortmasterCore" "Portmaster Application Firewall - Core Service"
StrCpy $oldInstallationDir "$COMMONPROGRAMDATA\Safing\Portmaster"
StrCpy $dataDir "$COMMONPROGRAMDATA\Portmaster"
@ -96,6 +97,14 @@ var dataDir
RMDir /r "$SMPROGRAMS\Portmaster"
Delete "$SMSTARTUP\Portmaster Notifier.lnk"
; Delete v1 uninstaller
Delete "$oldInstallationDir\portmaster-uninstaller.exe"
; Delete v1 user shortuct if there.
SetShellVarContext current
Delete "$AppData\Microsoft\Windows\Start Menu\Programs\Portmaster.lnk"
SetShellVarContext all
Finish:
!macroend