This commit is contained in:
Joeri 2026-02-07 12:12:53 +01:00
parent 674ee9f009
commit 838b07d998

View file

@ -486,40 +486,6 @@ $BleachBitCleaners = @(
"zoom.cache", "zoom.logs" "zoom.cache", "zoom.logs"
) )
# Download BleachBit Portable
Write-Log "Downloading BleachBit Portable..." -Level "INFO"
try {
$BleachBitUrl = "https://www.bleachbit.org/download/file/t?file=BleachBit-5.0.2-portable.zip"
$BleachBitZip = "C:\Quest\BleachBitPortable.zip"
Invoke-WebRequest -Uri $BleachBitUrl -OutFile $BleachBitZip -UseBasicParsing -ErrorAction Stop
$ScriptResult.bleachbit_cleanup.downloaded = $true
Write-Log "BleachBit Portable downloaded successfully." -Level "INFO"
} catch {
$ErrorMsg = "Failed to download BleachBit Portable: $($_.Exception.Message)"
$ScriptResult.bleachbit_cleanup.errors += $ErrorMsg
Write-Log $ErrorMsg -Level "ERROR"
}
# Extract BleachBit Portable
if ($ScriptResult.bleachbit_cleanup.downloaded) {
Write-Log "Extracting BleachBit Portable..." -Level "INFO"
try {
$BleachBitDest = "C:\Quest"
Expand-Archive -Path $BleachBitZip -DestinationPath $BleachBitDest -Force -ErrorAction Stop
$ScriptResult.bleachbit_cleanup.extracted = $true
Write-Log "BleachBit Portable extracted successfully." -Level "INFO"
# Remove zip file
Remove-Item $BleachBitZip -Force -ErrorAction SilentlyContinue
Write-Log "Removed temporary zip file." -Level "INFO"
} catch {
$ErrorMsg = "Failed to extract BleachBit Portable: $($_.Exception.Message)"
$ScriptResult.bleachbit_cleanup.errors += $ErrorMsg
Write-Log $ErrorMsg -Level "ERROR"
}
}
# Stop Edge processes # Stop Edge processes
Write-Log "Stopping Edge processes..." -Level "INFO" Write-Log "Stopping Edge processes..." -Level "INFO"
try { try {
@ -534,9 +500,27 @@ try {
Write-Log "Warning: Could not stop Edge processes: $($_.Exception.Message)" -Level "WARNING" Write-Log "Warning: Could not stop Edge processes: $($_.Exception.Message)" -Level "WARNING"
} }
# Run BleachBit cleanup # Check for installed BleachBit
$BleachBitExe = "C:\Quest\portableApps\BleachBit-Portable\bleachbit_console.exe" Write-Log "Checking for BleachBit installation..." -Level "INFO"
if (Test-Path $BleachBitExe) { $BleachBitExe = $null
# Check common installation paths
$PossiblePaths = @(
"C:\Program Files\BleachBit\bleachbit_console.exe",
"C:\Program Files (x86)\BleachBit\bleachbit_console.exe",
"C:\Quest\BleachBit-Portable\bleachbit_console.exe"
)
foreach ($Path in $PossiblePaths) {
if (Test-Path $Path) {
$BleachBitExe = $Path
Write-Log "Found BleachBit at: $BleachBitExe" -Level "INFO"
break
}
}
# Run BleachBit cleanup if found
if ($BleachBitExe) {
Write-Log "Running BleachBit cleanup with $($BleachBitCleaners.Count) cleaners..." -Level "INFO" Write-Log "Running BleachBit cleanup with $($BleachBitCleaners.Count) cleaners..." -Level "INFO"
try { try {
@ -547,16 +531,8 @@ if (Test-Path $BleachBitExe) {
$BleachBitProcess = Start-Process -FilePath $BleachBitExe -ArgumentList "--clean $CleanerArgs" -NoNewWindow -Wait -PassThru -ErrorAction Stop $BleachBitProcess = Start-Process -FilePath $BleachBitExe -ArgumentList "--clean $CleanerArgs" -NoNewWindow -Wait -PassThru -ErrorAction Stop
$ScriptResult.bleachbit_cleanup.cleaners_run = $BleachBitCleaners.Count $ScriptResult.bleachbit_cleanup.cleaners_run = $BleachBitCleaners.Count
$ScriptResult.bleachbit_cleanup.extracted = $true
Write-Log "BleachBit cleanup completed. Exit code: $($BleachBitProcess.ExitCode)" -Level "INFO" Write-Log "BleachBit cleanup completed. Exit code: $($BleachBitProcess.ExitCode)" -Level "INFO"
# Optionally delete BleachBit after use
try {
Write-Log "Cleaning up BleachBit Portable files..." -Level "INFO"
Remove-Item "C:\Quest\portableApps" -Recurse -Force -ErrorAction SilentlyContinue
Write-Log "BleachBit Portable files removed." -Level "INFO"
} catch {
Write-Log "Warning: Could not remove BleachBit files: $($_.Exception.Message)" -Level "WARNING"
}
} catch { } catch {
$ErrorMsg = "Failed to run BleachBit cleanup: $($_.Exception.Message)" $ErrorMsg = "Failed to run BleachBit cleanup: $($_.Exception.Message)"
$ScriptResult.bleachbit_cleanup.errors += $ErrorMsg $ScriptResult.bleachbit_cleanup.errors += $ErrorMsg
@ -564,7 +540,8 @@ if (Test-Path $BleachBitExe) {
Write-Log $ErrorMsg -Level "ERROR" Write-Log $ErrorMsg -Level "ERROR"
} }
} else { } else {
Write-Log "BleachBit executable not found at: $BleachBitExe" -Level "ERROR" Write-Log "BleachBit not found. Skipping cleanup." -Level "WARNING"
Write-Log "Install BleachBit to enable automatic cleanup." -Level "INFO"
} }
Write-Log "BleachBit cleanup section completed." -Level "INFO" Write-Log "BleachBit cleanup section completed." -Level "INFO"