This commit is contained in:
Joeri 2026-02-21 15:13:12 +01:00
parent c553198eef
commit 185ee6a02f

View file

@ -75,17 +75,33 @@ if (-not (Test-Path $exePath)) {
# Run the cleanup command and capture output # Run the cleanup command and capture output
Write-Host "Running BleachBit cleanup..." Write-Host "Running BleachBit cleanup..."
# Create temp files for output capture
$stdoutFile = "$InstallPath\bleachbit_stdout.txt"
$stderrFile = "$InstallPath\bleachbit_stderr.txt"
try { try {
# Use call operator (&) to capture output instead of Start-Process $process = Start-Process -FilePath $exePath -ArgumentList "--clean $CleanerArgs" -NoNewWindow -Wait -PassThru -RedirectStandardOutput $stdoutFile -RedirectStandardError $stderrFile -ErrorAction Stop
$output = & $exePath --clean $CleanerArgs 2>&1
# Convert output to string # Read the captured output
$outputText = $output | Out-String $outputText = ""
if (Test-Path $stdoutFile) {
$outputText = Get-Content -Path $stdoutFile -Raw -ErrorAction SilentlyContinue
}
if (Test-Path $stderrFile) {
$stderrText = Get-Content -Path $stderrFile -Raw -ErrorAction SilentlyContinue
if ($stderrText) {
$outputText += $stderrText
}
}
Write-Host $outputText Write-Host $outputText
} catch { } catch {
$outputText = "Error running BleachBit: $($_.Exception.Message)" $outputText = "Error running BleachBit: $($_.Exception.Message)"
Write-Host $outputText Write-Host $outputText
} finally {
# Cleanup temp files
if (Test-Path $stdoutFile) { Remove-Item $stdoutFile -ErrorAction SilentlyContinue }
if (Test-Path $stderrFile) { Remove-Item $stderrFile -ErrorAction SilentlyContinue }
} }
# Output JSON result # Output JSON result