From f09b44d15ea01b6fbe199a0e1f3cfb638dca2253 Mon Sep 17 00:00:00 2001 From: David Yoder Date: Tue, 22 Aug 2023 11:14:26 -0400 Subject: [PATCH] exit installer if agent is installed --- Install-LiquidFilesOutlookAgent.ps1 | 22 +++++++++++++++------- 1 file changed, 15 insertions(+), 7 deletions(-) diff --git a/Install-LiquidFilesOutlookAgent.ps1 b/Install-LiquidFilesOutlookAgent.ps1 index afe36f3..6c24459 100644 --- a/Install-LiquidFilesOutlookAgent.ps1 +++ b/Install-LiquidFilesOutlookAgent.ps1 @@ -1,6 +1,21 @@ # Path to the MSI installer $MSIURL = 'https://lfupdate.s3.amazonaws.com/clients/outlook/admin_msi/LiquidFiles_Admin_2.1.10.msi' +# Get path to the installed agent +$PathToAgentExe64 = "${Env:ProgramFiles(x86)}\LiquidFiles Windows Agent\LiquidFilesWindowsAgent.exe" +$PathToAgentExe32 = "${Env:ProgramFiles}\LiquidFiles Windows Agent\LiquidFilesWindowsAgent.exe" +If ( Test-Path $PathToAgentExe64 ) { + $PathToAgentExe = $PathToAgentExe64 +} ElseIf ( Test-Path $PathToAgentExe32 ) { + $PathToAgentExe = $PathToAgentExe32 +} + +# Exit this script if the agent is already installed +If ( Test-Path $PathToAgentExe ) { + LogMsg "LiquidFiles agent is already installed. This installer will exit." + Exit +} + # Set installer args If (-not [string]::IsNullOrEmpty($LFHost) ) { LogMsg "LiquidFiles target server: ${LFHost}" @@ -29,13 +44,6 @@ Try { Catch { LogErr $_.Exception.Message } # Start the agent -$PathToAgentExe64 = "${Env:ProgramFiles(x86)}\LiquidFiles Windows Agent\LiquidFilesWindowsAgent.exe" -$PathToAgentExe32 = "${Env:ProgramFiles}\LiquidFiles Windows Agent\LiquidFilesWindowsAgent.exe" -If ( Test-Path $PathToAgentExe64 ) { - $PathToAgentExe = $PathToAgentExe64 -} ElseIf ( Test-Path $PathToAgentExe32 ) { - $PathToAgentExe = $PathToAgentExe32 -} If ($PathToAgentExe) { LogMsg "Starting LiquidFiles agent" Try { Start-Process $PathToAgentExe }