From 038095a607ad1337b7ee2df6a7720c37626d380b Mon Sep 17 00:00:00 2001 From: Lightemerald Date: Thu, 20 Jun 2024 11:54:42 +0200 Subject: [PATCH] Fixed2 --- setupApps.ps1 | 43 ++++++++++++++++++++++--------------------- 1 file changed, 22 insertions(+), 21 deletions(-) diff --git a/setupApps.ps1 b/setupApps.ps1 index 5b794ab..22bd639 100644 --- a/setupApps.ps1 +++ b/setupApps.ps1 @@ -70,29 +70,30 @@ function InstallZip { [bool] $createSubfolder = $false, [string] $skipIf = $false ) - if (-not (Test-Path -Path $skipIf -PathType Container) -and $skipIf -ne $false) { - $zipName = [System.IO.Path]::GetFileNameWithoutExtension($zip) - Write-Host "Installing $zipName..." - $targetPath = $env:ProgramFiles - if ($createSubfolder) { - $subFolder = Join-Path $env:ProgramFiles $zipName - if (-not (Test-Path -Path $subFolder -PathType Container)) { - New-Item -Path $subFolder -ItemType Directory - } - $targetPath = $subFolder - } - if (Test-Path -Path (Join-Path $targetPath $app) -PathType Container) { - Remove-Item -Path (Join-Path $targetPath $app) -Recurse -Force - } - Expand-Archive -Path (Join-Path $tmpPath $zip) -DestinationPath $targetPath -Force - if (-not $zipName.Equals($app) -and (-not (Test-Path -Path (Join-Path $targetPath $app) -PathType Container))) { - Start-Sleep -s 2 - Move-Item -Path (Join-Path $env:ProgramFiles $zipName) -Destination (Join-Path $env:ProgramFiles $app) - } - CreateShortcut -exe $(Join-Path -Path $env:ProgramFiles -ChildPath (Join-Path -Path $app -ChildPath $exe)) -app $app - } else { + if ($skipIf -ne $false -and (Test-Path -Path $skipIf -PathType Container)) { Write-Host "$app already installed." } + } else { + $zipName = [System.IO.Path]::GetFileNameWithoutExtension($zip) + Write-Host "Installing $zipName..." + $targetPath = $env:ProgramFiles + if ($createSubfolder) { + $subFolder = Join-Path $env:ProgramFiles $zipName + if (-not (Test-Path -Path $subFolder -PathType Container)) { + New-Item -Path $subFolder -ItemType Directory + } + $targetPath = $subFolder + } + if (Test-Path -Path (Join-Path $targetPath $app) -PathType Container) { + Remove-Item -Path (Join-Path $targetPath $app) -Recurse -Force + } + Expand-Archive -Path (Join-Path $tmpPath $zip) -DestinationPath $targetPath -Force + if (-not $zipName.Equals($app) -and (-not (Test-Path -Path (Join-Path $targetPath $app) -PathType Container))) { + Start-Sleep -s 2 + Move-Item -Path (Join-Path $env:ProgramFiles $zipName) -Destination (Join-Path $env:ProgramFiles $app) + } + CreateShortcut -exe $(Join-Path -Path $env:ProgramFiles -ChildPath (Join-Path -Path $app -ChildPath $exe)) -app $app + } } function CreateShortcut {