This commit is contained in:
Joeri 2026-02-21 15:11:38 +01:00
parent ba10048c95
commit c553198eef

View file

@ -1,10 +1,8 @@
# BleachBit Script # BleachBit Script
# Downloads BleachBit portable, extracts it, and runs the cleanup command # Downloads BleachBit portable, extracts it, and runs the cleanup command
param( param(
[string]$InstallPath = "C:\Quest" [string]$InstallPath = "C:\Quest"
) )
$BleachBitCleaners = @( $BleachBitCleaners = @(
"adobe_reader.cache", "adobe_reader.mru", "adobe_reader.tmp", "adobe_reader.cache", "adobe_reader.mru", "adobe_reader.tmp",
"amule.known_clients", "amule.known_files", "amule.logs", "amule.temp", "amule.known_clients", "amule.known_files", "amule.logs", "amule.temp",
@ -45,7 +43,6 @@ $BleachBitCleaners = @(
"yahoo_messenger.cache", "yahoo_messenger.chat_logs", "yahoo_messenger.logs", "yahoo_messenger.cache", "yahoo_messenger.chat_logs", "yahoo_messenger.logs",
"zoom.cache", "zoom.logs" "zoom.cache", "zoom.logs"
) )
Write-Host "Stopping Edge processes..." Write-Host "Stopping Edge processes..."
try { try {
$EdgeProcesses = Get-Process -Name "*Edge*" -ErrorAction SilentlyContinue $EdgeProcesses = Get-Process -Name "*Edge*" -ErrorAction SilentlyContinue
@ -58,37 +55,43 @@ try {
} catch { } catch {
Write-Host "Warning: Could not stop Edge processes: $($_.Exception.Message)" Write-Host "Warning: Could not stop Edge processes: $($_.Exception.Message)"
} }
$DownloadURL = "https://download.bleachbit.org/BleachBit-5.0.2-portable.zip" $DownloadURL = "https://download.bleachbit.org/BleachBit-5.0.2-portable.zip"
$zipPath = "$InstallPath\BleachBit.zip" $zipPath = "$InstallPath\BleachBit.zip"
$exePath = "$InstallPath\BleachBit-Portable\bleachbit_console.exe" $exePath = "$InstallPath\BleachBit-Portable\bleachbit_console.exe"
# Create directory if it doesn't exist # Create directory if it doesn't exist
if (-not (Test-Path $InstallPath)) { if (-not (Test-Path $InstallPath)) {
New-Item -Path $InstallPath -ItemType Directory -Force | Out-Null New-Item -Path $InstallPath -ItemType Directory -Force | Out-Null
} }
# Download if not exists # Download if not exists
if (-not (Test-Path $zipPath)) { if (-not (Test-Path $zipPath)) {
Write-Host "Downloading BleachBit..." Write-Host "Downloading BleachBit..."
Invoke-WebRequest -Uri $DownloadURL -OutFile $zipPath -UseBasicParsing Invoke-WebRequest -Uri $DownloadURL -OutFile $zipPath -UseBasicParsing
} }
# Extract if exe doesn't exist # Extract if exe doesn't exist
if (-not (Test-Path $exePath)) { if (-not (Test-Path $exePath)) {
Write-Host "Extracting BleachBit..." Write-Host "Extracting BleachBit..."
Expand-Archive -Path $zipPath -DestinationPath $InstallPath -Force Expand-Archive -Path $zipPath -DestinationPath $InstallPath -Force
} }
# Run the cleanup command and capture output
# Run the cleanup command
Write-Host "Running BleachBit cleanup..." Write-Host "Running BleachBit cleanup..."
$CleanerArgs = $BleachBitCleaners -join " "
$output = Start-Process -FilePath $exePath -ArgumentList "--clean $CleanerArgs" -NoNewWindow -Wait -PassThru -ErrorAction Stop try {
# Use call operator (&) to capture output instead of Start-Process
$output = & $exePath --clean $CleanerArgs 2>&1
# Convert output to string
$outputText = $output | Out-String
Write-Host $outputText
} catch {
$outputText = "Error running BleachBit: $($_.Exception.Message)"
Write-Host $outputText
}
# Output JSON result # Output JSON result
$result = @{ $result = @{
success = $true success = $true
output = $output output = $outputText
} | ConvertTo-Json -Compress } | ConvertTo-Json -Compress
Write-Output $result Write-Output $result