# Remove the AdBlock-Maxxer YouTube companion auto-start + stop any running hidden instance.
$ErrorActionPreference = "SilentlyContinue"

$startup = [Environment]::GetFolderPath("Startup")
$lnk     = Join-Path $startup "AdBlock-Maxxer YouTube Companion.lnk"
if (Test-Path $lnk) { Remove-Item $lnk -Force; Write-Host "Removed startup shortcut." }
else { Write-Host "No startup shortcut found." }

# Stop the standalone companion exe (onedir/onefile builds)
Get-CimInstance Win32_Process -Filter "Name='abm-companion.exe'" |
  ForEach-Object { Stop-Process -Id $_.ProcessId -Force; Write-Host ("Stopped companion exe pid " + $_.ProcessId) }

# Stop any pythonw running our companion script (dev / from-source runs)
Get-CimInstance Win32_Process -Filter "Name='pythonw.exe'" |
  Where-Object { $_.CommandLine -like "*abm_companion.py*" } |
  ForEach-Object { Stop-Process -Id $_.ProcessId -Force; Write-Host ("Stopped companion pid " + $_.ProcessId) }

Write-Host "Auto-start removed. (You can still run start-companion.bat manually.)"
