fix
This commit is contained in:
1 parent
2de2d7c36f
commit
2f96eee4ad
1 file changed
+54
-20
+54
-20
@@ -321,22 +321,39 @@ function Install-MedewerkersApps {
|
||||
Write-ColorText "[$currentApp/$totalApps] Installeer $app..." "Cyan"
|
||||
|
||||
try {
|
||||
$process = Start-Process -NoNewWindow -Wait -FilePath "winget" -ArgumentList "install --id $app -e --silent --accept-package-agreements --accept-source-agreements --source winget --scope machine" -PassThru
|
||||
# Capture both output and error streams
|
||||
$outputFile = "$env:TEMP\winget_$(Get-Random).txt"
|
||||
$errorFile = "$env:TEMP\winget_error_$(Get-Random).txt"
|
||||
|
||||
$process = Start-Process -NoNewWindow -Wait -FilePath "winget" -ArgumentList "install --id $app -e --silent --accept-package-agreements --accept-source-agreements --source winget --scope machine" -PassThru -RedirectStandardOutput $outputFile -RedirectStandardError $errorFile
|
||||
$exitCode = $process.ExitCode
|
||||
|
||||
# Check exit codes: 0 = success, 0x8A150011 = package already installed, others = errors
|
||||
if ($exitCode -eq 0 -or $exitCode -eq 0x8A150011) {
|
||||
if ($exitCode -eq 0x8A150011) {
|
||||
Write-ColorText "✓ $app is al geïnstalleerd" "Yellow"
|
||||
} else {
|
||||
Write-ColorText "✓ $app succesvol geïnstalleerd" "Green"
|
||||
}
|
||||
# Read output to determine actual result
|
||||
$outputContent = ""
|
||||
$errorContent = ""
|
||||
if (Test-Path $outputFile) {
|
||||
$outputContent = Get-Content $outputFile -Raw -ErrorAction SilentlyContinue
|
||||
Remove-Item $outputFile -Force -ErrorAction SilentlyContinue
|
||||
}
|
||||
if (Test-Path $errorFile) {
|
||||
$errorContent = Get-Content $errorFile -Raw -ErrorAction SilentlyContinue
|
||||
Remove-Item $errorFile -Force -ErrorAction SilentlyContinue
|
||||
}
|
||||
|
||||
# Check for success indicators in output
|
||||
$combinedOutput = "$outputContent $errorContent"
|
||||
if ($combinedOutput -match "Successfully installed" -or $exitCode -eq 0) {
|
||||
Write-ColorText "✓ $app succesvol geïnstalleerd" "Green"
|
||||
} elseif ($combinedOutput -match "already installed|No applicable|No available upgrade" -or ($null -ne $exitCode -and $exitCode -ne 0)) {
|
||||
Write-ColorText "✓ $app is al geïnstalleerd (geen actie nodig)" "Yellow"
|
||||
} else {
|
||||
Write-ColorText "✗ Fout bij installatie van $app (Exit code: $exitCode)" "Red"
|
||||
Write-ColorText "✗ Fout bij installatie van $app" "Red"
|
||||
}
|
||||
} catch {
|
||||
Write-ColorText "✗ Fout bij installatie van $app" "Red"
|
||||
Write-ColorText "Foutdetails: $($_.Exception.Message)" "Red"
|
||||
if ($_.Exception.Message) {
|
||||
Write-ColorText "Foutdetails: $($_.Exception.Message)" "Red"
|
||||
}
|
||||
}
|
||||
|
||||
Write-Host ""
|
||||
@@ -407,22 +424,39 @@ function Install-GastenApps {
|
||||
Write-ColorText "[$currentApp/$totalApps] Installeer $app..." "Cyan"
|
||||
|
||||
try {
|
||||
$process = Start-Process -NoNewWindow -Wait -FilePath "winget" -ArgumentList "install --id $app -e --silent --accept-package-agreements --accept-source-agreements --source winget --scope machine" -PassThru
|
||||
# Capture both output and error streams
|
||||
$outputFile = "$env:TEMP\winget_$(Get-Random).txt"
|
||||
$errorFile = "$env:TEMP\winget_error_$(Get-Random).txt"
|
||||
|
||||
$process = Start-Process -NoNewWindow -Wait -FilePath "winget" -ArgumentList "install --id $app -e --silent --accept-package-agreements --accept-source-agreements --source winget --scope machine" -PassThru -RedirectStandardOutput $outputFile -RedirectStandardError $errorFile
|
||||
$exitCode = $process.ExitCode
|
||||
|
||||
# Check exit codes: 0 = success, 0x8A150011 = package already installed, others = errors
|
||||
if ($exitCode -eq 0 -or $exitCode -eq 0x8A150011) {
|
||||
if ($exitCode -eq 0x8A150011) {
|
||||
Write-ColorText "✓ $app is al geïnstalleerd" "Yellow"
|
||||
} else {
|
||||
Write-ColorText "✓ $app succesvol geïnstalleerd" "Green"
|
||||
}
|
||||
# Read output to determine actual result
|
||||
$outputContent = ""
|
||||
$errorContent = ""
|
||||
if (Test-Path $outputFile) {
|
||||
$outputContent = Get-Content $outputFile -Raw -ErrorAction SilentlyContinue
|
||||
Remove-Item $outputFile -Force -ErrorAction SilentlyContinue
|
||||
}
|
||||
if (Test-Path $errorFile) {
|
||||
$errorContent = Get-Content $errorFile -Raw -ErrorAction SilentlyContinue
|
||||
Remove-Item $errorFile -Force -ErrorAction SilentlyContinue
|
||||
}
|
||||
|
||||
# Check for success indicators in output
|
||||
$combinedOutput = "$outputContent $errorContent"
|
||||
if ($combinedOutput -match "Successfully installed" -or $exitCode -eq 0) {
|
||||
Write-ColorText "✓ $app succesvol geïnstalleerd" "Green"
|
||||
} elseif ($combinedOutput -match "already installed|No applicable|No available upgrade" -or ($null -ne $exitCode -and $exitCode -ne 0)) {
|
||||
Write-ColorText "✓ $app is al geïnstalleerd (geen actie nodig)" "Yellow"
|
||||
} else {
|
||||
Write-ColorText "✗ Fout bij installatie van $app (Exit code: $exitCode)" "Red"
|
||||
Write-ColorText "✗ Fout bij installatie van $app" "Red"
|
||||
}
|
||||
} catch {
|
||||
Write-ColorText "✗ Fout bij installatie van $app" "Red"
|
||||
Write-ColorText "Foutdetails: $($_.Exception.Message)" "Red"
|
||||
if ($_.Exception.Message) {
|
||||
Write-ColorText "Foutdetails: $($_.Exception.Message)" "Red"
|
||||
}
|
||||
}
|
||||
|
||||
Write-Host ""
|
||||
|
||||
Reference in new issue
Block a user