#Requires -Version 5.1 <# .SYNOPSIS Bakodoro complete uninstaller. .DESCRIPTION Kills running instances, removes scheduled tasks, deletes all installed files/directories, and cleans up Windows Defender exclusions for every version of Bakodoro that may be present on the machine. Run as the same user who ran the installer (no elevation required for most steps; elevation is only needed to remove Defender exclusions). If you want Defender exclusions removed too, right-click → Run as Administrator. #> Set-StrictMode -Version Latest $ErrorActionPreference = 'SilentlyContinue' $Banner = @" ============================================================= Bakodoro Uninstaller ============================================================= "@ Write-Host $Banner -ForegroundColor Cyan # ───────────────────────────────────────────────────────────── # Helpers # ───────────────────────────────────────────────────────────── function Remove-HiddenItem { param([string]$Path) if (-not (Test-Path $Path)) { return } try { # Strip hidden + system so PowerShell can delete it attrib -H -S "$Path" 2>$null Remove-Item -LiteralPath $Path -Force -Recurse Write-Host " [REMOVED] $Path" -ForegroundColor Green } catch { Write-Host " [WARN] Could not remove: $Path ($_)" -ForegroundColor Yellow } } function Kill-ProcessByName { param([string]$Name) $procs = Get-Process -Name $Name -ErrorAction SilentlyContinue if ($procs) { $procs | Stop-Process -Force Write-Host " [KILLED] $Name (PID $($procs.Id -join ', '))" -ForegroundColor Green } } function Remove-ScheduledTaskSilent { param([string]$TaskName) $task = Get-ScheduledTask -TaskName $TaskName -ErrorAction SilentlyContinue if ($task) { Unregister-ScheduledTask -TaskName $TaskName -Confirm:$false Write-Host " [REMOVED TASK] $TaskName" -ForegroundColor Green } } function Remove-DefenderExclusion { param([string]$Path, [string]$Process) try { if ($Path) { Remove-MpPreference -ExclusionPath $Path -ErrorAction Stop } if ($Process) { Remove-MpPreference -ExclusionProcess $Process -ErrorAction Stop } Write-Host " [REMOVED EXCLUSION] Path='$Path' Process='$Process'" -ForegroundColor Green } catch { # Silently ignore — Defender may not be present or no exclusion existed } } # ───────────────────────────────────────────────────────────── # Resolve machine short ID (used as exe/task/dir name) # ───────────────────────────────────────────────────────────── $machineIdFile = Join-Path $env:USERPROFILE ".computermachine_id" $shortId = $null if (Test-Path $machineIdFile) { try { $fullUuid = (Get-Content $machineIdFile -Raw).Trim() # Strip hyphens to get raw hex, then take first 8 chars $shortId = ($fullUuid -replace '-', '').Substring(0, 8) Write-Host "[*] Detected machine short ID: $shortId" -ForegroundColor Cyan } catch { Write-Host "[WARN] Could not read machine_id file; will scan for installs." -ForegroundColor Yellow } } # ───────────────────────────────────────────────────────────── # Collect all candidate short IDs to clean # 1. From machine_id file (above) # 2. From directories under %LOCALAPPDATA%Programs that look like # an 8-hex-char bakodoro install (contain a matching .exe/.vbs) # 3. From Task Scheduler tasks ending in "Session" with an 8-char prefix # ───────────────────────────────────────────────────────────── $candidateIds = [System.Collections.Generic.HashSet[string]]::new() if ($shortId) { [void]$candidateIds.Add($shortId) } # Scan Programs directory $programsDir = Join-Path $env:LOCALAPPDATA "Programs" if (Test-Path $programsDir) { Get-ChildItem -LiteralPath $programsDir -Directory | ForEach-Object { $dirName = $_.Name # 8 hex characters if ($dirName -match '^[0-9a-f]{8}$') { [void]$candidateIds.Add($dirName) } } } # Scan Task Scheduler (root folder) for tasks ending with "Session" whose # prefix is 8 hex characters — these are bakodoro autorun tasks try { $scheduler = New-Object -ComObject Schedule.Service $scheduler.Connect() $rootFolder = $scheduler.GetFolder('') $rootFolder.GetTasks(0) | ForEach-Object { $tName = $_.Name if ($tName -match '^([0-9a-f]{8})Session$') { [void]$candidateIds.Add($Matches[1]) } } } catch { } Write-Host "[*] Candidate IDs to clean: $($candidateIds -join ', ')" -ForegroundColor Cyan Write-Host "" # ───────────────────────────────────────────────────────────── # STEP 1 — Kill processes # ───────────────────────────────────────────────────────────── Write-Host "--- Step 1: Killing running processes ---" -ForegroundColor White # Legacy Kill-ProcessByName "watchora" Kill-ProcessByName "bakodoro" # Current installs foreach ($id in $candidateIds) { Kill-ProcessByName $id } Start-Sleep -Milliseconds 800 # give OS a moment to release file locks # ───────────────────────────────────────────────────────────── # STEP 2 — Remove scheduled tasks # ───────────────────────────────────────────────────────────── Write-Host "" Write-Host "--- Step 2: Removing scheduled tasks ---" -ForegroundColor White Remove-ScheduledTaskSilent "WatchoraSession" foreach ($id in $candidateIds) { Remove-ScheduledTaskSilent "$($id)Session" } # ───────────────────────────────────────────────────────────── # STEP 3 — Remove install directories # ───────────────────────────────────────────────────────────── Write-Host "" Write-Host "--- Step 3: Removing install directories ---" -ForegroundColor White # Legacy watchora directory $legacyDir = Join-Path $env:LOCALAPPDATA "Programswatchora" Remove-HiddenItem $legacyDir # Current installs foreach ($id in $candidateIds) { $installDir = Join-Path $env:LOCALAPPDATA "Programs$id" Remove-HiddenItem $installDir } # ───────────────────────────────────────────────────────────── # STEP 4 — Remove machine identity files # ───────────────────────────────────────────────────────────── Write-Host "" Write-Host "--- Step 4: Removing machine identity files ---" -ForegroundColor White # Old ~/.computer/machine_id location $computerDir = Join-Path $env:USERPROFILE ".computer" Remove-HiddenItem $computerDir # New location: %LOCALAPPDATA%MicrosoftWindowsShell humbcache.dat $thumbcache = Join-Path $env:LOCALAPPDATA "MicrosoftWindowsShell humbcache.dat" Remove-HiddenItem $thumbcache # ───────────────────────────────────────────────────────────── # STEP 5 — Remove zrok environment # ───────────────────────────────────────────────────────────── Write-Host "" Write-Host "--- Step 5: Removing zrok environment (~.zrok) ---" -ForegroundColor White $zrokDir = Join-Path $env:USERPROFILE ".zrok" Remove-HiddenItem $zrokDir # ───────────────────────────────────────────────────────────── # STEP 6 — Remove Windows Defender exclusions # ───────────────────────────────────────────────────────────── Write-Host "" Write-Host "--- Step 6: Removing Windows Defender exclusions ---" -ForegroundColor White # Legacy Remove-DefenderExclusion -Path (Join-Path $env:LOCALAPPDATA "Programswatchora") -Process "watchora.exe" foreach ($id in $candidateIds) { $installDir = Join-Path $env:LOCALAPPDATA "Programs$id" Remove-DefenderExclusion -Path $installDir -Process "$id.exe" } # ───────────────────────────────────────────────────────────── # Done # ───────────────────────────────────────────────────────────── Write-Host "" Write-Host "==============================================================" -ForegroundColor Cyan Write-Host " Uninstall complete." -ForegroundColor Green Write-Host " If Defender exclusions were not removed, re-run as Admin." -ForegroundColor Yellow Write-Host "==============================================================" -ForegroundColor Cyan