From 498139be7d015023a2cef1dca79e4506edd6f4e5 Mon Sep 17 00:00:00 2001
From: "kali kaneko (leap communications)" <kali@leap.se>
Date: Wed, 22 Apr 2020 18:35:27 +0200
Subject: [PATCH] [pkg] fail-safe for uninstaller

---
 branding/templates/windows/template.nsi | 8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)

diff --git a/branding/templates/windows/template.nsi b/branding/templates/windows/template.nsi
index e98854f9..ce05d27c 100755
--- a/branding/templates/windows/template.nsi
+++ b/branding/templates/windows/template.nsi
@@ -98,7 +98,13 @@ Section /o "TAP Virtual Ethernet Adapter" SecTAP
 SectionEnd
 
 Section "Uninstall"
-  ExecShellWait "runas" "$INSTDIR\bitmask_helper.exe" 'remove'
+  ; this could fail: uninstalling old nssm helper
+  ExecShellWait "runas" '"$INSTDIR\nssm.exe" stop $applicationNameLower-helper'
+  ExecShellWait "runas" '"$INSTDIR\nssm.exe" remove $applicationNameLower-helper confirm'
+
+  ; now we uninstall the new-style go helper
+  ExecShellWait "runas" '"$INSTDIR\bitmask_helper.exe" remove'
+
 
   Delete $INSTDIR\readme.txt
   Delete $INSTDIR\helper.log
-- 
GitLab