This commit is contained in:
2024-06-20 11:54:42 +02:00
parent 5411c0dace
commit 038095a607

View File

@@ -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 {