-
This commit is contained in:
parent
674ee9f009
commit
838b07d998
1 changed files with 24 additions and 47 deletions
71
cleanup.ps1
71
cleanup.ps1
|
|
@ -486,40 +486,6 @@ $BleachBitCleaners = @(
|
|||
"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
|
||||
Write-Log "Stopping Edge processes..." -Level "INFO"
|
||||
try {
|
||||
|
|
@ -534,9 +500,27 @@ try {
|
|||
Write-Log "Warning: Could not stop Edge processes: $($_.Exception.Message)" -Level "WARNING"
|
||||
}
|
||||
|
||||
# Run BleachBit cleanup
|
||||
$BleachBitExe = "C:\Quest\portableApps\BleachBit-Portable\bleachbit_console.exe"
|
||||
if (Test-Path $BleachBitExe) {
|
||||
# Check for installed BleachBit
|
||||
Write-Log "Checking for BleachBit installation..." -Level "INFO"
|
||||
$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"
|
||||
|
||||
try {
|
||||
|
|
@ -547,16 +531,8 @@ if (Test-Path $BleachBitExe) {
|
|||
$BleachBitProcess = Start-Process -FilePath $BleachBitExe -ArgumentList "--clean $CleanerArgs" -NoNewWindow -Wait -PassThru -ErrorAction Stop
|
||||
|
||||
$ScriptResult.bleachbit_cleanup.cleaners_run = $BleachBitCleaners.Count
|
||||
$ScriptResult.bleachbit_cleanup.extracted = $true
|
||||
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 {
|
||||
$ErrorMsg = "Failed to run BleachBit cleanup: $($_.Exception.Message)"
|
||||
$ScriptResult.bleachbit_cleanup.errors += $ErrorMsg
|
||||
|
|
@ -564,7 +540,8 @@ if (Test-Path $BleachBitExe) {
|
|||
Write-Log $ErrorMsg -Level "ERROR"
|
||||
}
|
||||
} 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"
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue