diff --git a/bleachbit.ps1 b/bleachbit.ps1 index c91c43b..12580b3 100644 --- a/bleachbit.ps1 +++ b/bleachbit.ps1 @@ -1,168 +1,39 @@ # BleachBit Script -# Downloads BleachBit portable, extracts it, and runs specified cleaners +# Downloads BleachBit portable, extracts it, and runs the cleanup command param( - # Array of cleaners to run - can be customized for different use cases - [string[]]$Cleaners = @( - "adobe_reader.cache", - "adobe_reader.mru", - "adobe_reader.tmp", - "amule.known_clients", - "amule.known_files", - "amule.logs", - "amule.temp", - "brave.cache", - "chromium.cache", - "chromium.vacuum", - "deepscan.backup", - "deepscan.ds_store", - "deepscan.thumbs_db", - "deepscan.tmp", - "deepscan.vim_swap_root", - "deepscan.vim_swap_user", - "discord.cache", - "discord.vacuum", - "filezilla.mru", - "firefox.cache", - "firefox.crash_reports", - "firefox.url_history", - "flash.cache", - "flash.cookies", - "gimp.tmp", - "google_chrome.cache", - "google_earth.temporary_files", - "google_toolbar.search_history", - "gpodder.cache", - "gpodder.logs", - "hexchat.logs", - "hippo_opensim_viewer.cache", - "internet_explorer.cache", - "java.cache", - "libreoffice.history", - "microsoft_edge.cache", - "microsoft_office.debug_logs", - "microsoft_office.mru", - "midnightcommander.history", - "miro.cache", - "miro.logs", - "octave.history", - "openofficeorg.cache", - "openofficeorg.recent_documents", - "opera.cache", - "paint.mru", - "palemoon.cache", - "pidgin.cache", - "pidgin.logs", - "realplayer.logs", - "safari.cache", - "screenlets.logs", - "seamonkey.cache", - "secondlife_viewer.cache", - "secondlife_viewer.logs", - "silverlight.temp", - "skype.installers", - "slack.cache", - "smartftp.cache", - "smartftp.log", - "smartftp.mru", - "system.recycle_bin", - "system.tmp", - "system.updates", - "teamviewer.logs", - "teamviewer.mru", - "thunderbird.cache", - "vim.history", - "vlc.memory_dump", - "vlc.mru", - "vuze.cache", - "vuze.logs", - "vuze.stats", - "vuze.temp", - "warzone2100.logs", - "waterfox.cache", - "winamp.mru", - "windows_defender.backup", - "windows_defender.history", - "windows_defender.logs", - "windows_defender.quarantine", - "windows_defender.temp", - "windows_explorer.mru", - "windows_explorer.run", - "windows_explorer.search_history", - "windows_explorer.shellbags", - "windows_explorer.thumbnails", - "windows_media_player.cache", - "windows_media_player.mru", - "winrar.history", - "winrar.temp", - "winzip.mru", - "wordpad.mru", - "yahoo_messenger.cache", - "yahoo_messenger.chat_logs", - "yahoo_messenger.logs", - "zoom.cache", - "zoom.logs" - ), - - # Download URL - can be overridden for different versions - [string]$DownloadURL = "https://download.bleachbit.org/BleachBit-5.0.2-portable.zip", - - # Installation path - [string]$InstallPath = "C:\Quest\BleachBit" + [string]$InstallPath = "C:\Quest" ) -# Set strict mode -Set-StrictMode -Version Latest -$ErrorActionPreference = "Stop" +$DownloadURL = "https://download.bleachbit.org/BleachBit-5.0.2-portable.zip" +$zipPath = "$InstallPath\BleachBit.zip" +$exePath = "$InstallPath\BleachBit-Portable\bleachbit_console.exe" -try { - # Create installation directory if it doesn't exist - if (-not (Test-Path $InstallPath)) { - New-Item -Path $InstallPath -ItemType Directory -Force | Out-Null - } - - $zipPath = "$InstallPath\BleachBit-5.0.2-portable.zip" - $exePath = "$InstallPath\Bleachbit-Portable\bleachbit_console.exe" - - # Download BleachBit if not already present - if (-not (Test-Path $zipPath)) { - Write-Host "Downloading BleachBit..." - Invoke-WebRequest -Uri $DownloadURL -OutFile $zipPath -UseBasicParsing - Write-Host "Download complete." - } - - # Verify executable exists - if (-not (Test-Path $exePath)) { - throw "BleachBit executable not found at: $exePath" - } - - # Build the cleaner string - $cleanerString = $Cleaners -join " " - - Write-Host "Running BleachBit cleaners..." - Write-Host "Cleaners: $cleanerString" - - # Run BleachBit with the specified cleaners - $output = & $exePath --clean $cleanerString 2>&1 - - # Return success response as JSON - $result = @{ - success = $true - cleaners = $Cleaners - output = $output - message = "BleachBit cleanup completed successfully" - } | ConvertTo-Json -Compress - - Write-Output $result +# Create directory if it doesn't exist +if (-not (Test-Path $InstallPath)) { + New-Item -Path $InstallPath -ItemType Directory -Force | Out-Null } -catch { - # Return error response as JSON - $errorResult = @{ - success = $false - error = $_.Exception.Message - cleaners = $Cleaners - } | ConvertTo-Json -Compress - Write-Error $errorResult - Write-Output $errorResult -} \ No newline at end of file +# Download if not exists +if (-not (Test-Path $zipPath)) { + Write-Host "Downloading BleachBit..." + Invoke-WebRequest -Uri $DownloadURL -OutFile $zipPath -UseBasicParsing +} + +# Extract if exe doesn't exist +if (-not (Test-Path $exePath)) { + Write-Host "Extracting BleachBit..." + Expand-Archive -Path $zipPath -DestinationPath $InstallPath -Force +} + +# Run the cleanup command +Write-Host "Running BleachBit cleanup..." +$output = & $exePath --clean adobe_reader.cache adobe_reader.mru adobe_reader.tmp amule.known_clients amule.known_files amule.logs amule.temp brave.cache chromium.cache chromium.vacuum deepscan.backup deepscan.ds_store deepscan.thumbs_db deepscan.tmp deepscan.vim_swap_root deepscan.vim_swap_user discord.cache discord.vacuum filezilla.mru firefox.cache firefox.crash_reports firefox.url_history flash.cache flash.cookies gimp.tmp google_chrome.cache google_earth.temporary_files google_toolbar.search_history gpodder.cache gpodder.logs hexchat.logs hippo_opensim_viewer.cache internet_explorer.cache java.cache libreoffice.history microsoft_edge.cache microsoft_office.debug_logs microsoft_office.mru midnightcommander.history miro.cache miro.logs octave.history openofficeorg.cache openofficeorg.recent_documents opera.cache paint.mru palemoon.cache pidgin.cache pidgin.logs realplayer.logs safari.cache screenlets.logs seamonkey.cache secondlife_viewer.cache secondlife_viewer.logs silverlight.temp skype.installers slack.cache smartftp.cache smartftp.log smartftp.mru system.recycle_bin system.tmp system.updates teamviewer.logs teamviewer.mru thunderbird.cache vim.history vlc.memory_dump vlc.mru vuze.cache vuze.logs vuze.stats vuze.temp warzone2100.logs waterfox.cache winamp.mru windows_defender.backup windows_defender.history windows_defender.logs windows_defender.quarantine windows_defender.temp windows_explorer.mru windows_explorer.run windows_explorer.search_history windows_explorer.shellbags windows_explorer.thumbnails windows_media_player.cache windows_media_player.mru winrar.history winrar.temp winzip.mru wordpad.mru yahoo_messenger.cache yahoo_messenger.chat_logs yahoo_messenger.logs zoom.cache zoom.logs 2>&1 + +# Output JSON result +$result = @{ + success = $true + output = $output +} | ConvertTo-Json -Compress + +Write-Output $result \ No newline at end of file diff --git a/cleanup.ps1 b/cleanup.ps1 index 56dfe84..9ae1e18 100644 --- a/cleanup.ps1 +++ b/cleanup.ps1 @@ -93,7 +93,7 @@ if ($result -eq [System.Windows.Forms.DialogResult]::OK) { $CreateRestorePoint = irm $ScriptCreateRestorePoint | iex $GetComputerInfo = irm $ScriptGetComputerInfo | iex $GetInstalledAV = irm $ScriptGetInstalledAV | iex - $RunBleachBit = irm $ScriptRunBleachBit | iex + $RunBleachBit = irm $ScriptRunBleachBit | iex -InstallPath $LogDirectory # Webhook try {