From 420b1786750ccdc4b48d9858156b146aef8d0e97 Mon Sep 17 00:00:00 2001
From: Niko Ehrenfeuchter <nikolaus.ehrenfeuchter@unibas.ch>
Date: Tue, 6 Feb 2018 14:30:17 +0100
Subject: [PATCH] Shut down tray app before updating the service.

Closes #27
---
 Updater/Update-Service.ps1 | 12 ++++++++++++
 1 file changed, 12 insertions(+)

diff --git a/Updater/Update-Service.ps1 b/Updater/Update-Service.ps1
index d52e007..7e3333b 100644
--- a/Updater/Update-Service.ps1
+++ b/Updater/Update-Service.ps1
@@ -52,6 +52,17 @@ function ServiceIsBusy {
     }
 }
 
+function Stop-TrayApp() {
+    try {
+        Stop-Process -Name "ATxTray" -Force -ErrorAction Stop
+        Start-Sleep -Milliseconds 200
+        Log-Debug "Stopped Tray App process."
+    }
+    catch {
+        Log-Debug "Unable to stop tray app, is it running?"
+    }
+}
+
 
 function Exit-IfDirMissing([string]$DirName, [string]$Desc) {
     if (Test-Path -PathType Container $DirName) {
@@ -279,6 +290,7 @@ function Update-ServiceBinaries {
         Log-Debug "Found marker [$($MarkerFile)], not updating service."
         Return $False
     }
+    Stop-TrayApp
     Copy-ServiceFiles
     try {
         New-Item -Type File "$MarkerFile" -ErrorAction Stop | Out-Null
-- 
GitLab