-
This commit is contained in:
parent
c553198eef
commit
185ee6a02f
1 changed files with 20 additions and 4 deletions
|
|
@ -75,17 +75,33 @@ if (-not (Test-Path $exePath)) {
|
|||
# Run the cleanup command and capture output
|
||||
Write-Host "Running BleachBit cleanup..."
|
||||
|
||||
try {
|
||||
# Use call operator (&) to capture output instead of Start-Process
|
||||
$output = & $exePath --clean $CleanerArgs 2>&1
|
||||
# Create temp files for output capture
|
||||
$stdoutFile = "$InstallPath\bleachbit_stdout.txt"
|
||||
$stderrFile = "$InstallPath\bleachbit_stderr.txt"
|
||||
|
||||
# Convert output to string
|
||||
$outputText = $output | Out-String
|
||||
try {
|
||||
$process = Start-Process -FilePath $exePath -ArgumentList "--clean $CleanerArgs" -NoNewWindow -Wait -PassThru -RedirectStandardOutput $stdoutFile -RedirectStandardError $stderrFile -ErrorAction Stop
|
||||
|
||||
# Read the captured output
|
||||
$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
|
||||
} catch {
|
||||
$outputText = "Error running BleachBit: $($_.Exception.Message)"
|
||||
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
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue