# QwenClaw Windows Startup Uninstaller
# Run this to remove QwenClaw from Windows startup

$ErrorActionPreference = "Stop"

$TASK_NAME = "QwenClaw Daemon"
$STARTUP_FOLDER = [Environment]::GetFolderPath("Startup")

Write-Host "QwenClaw Windows Startup Uninstaller" -ForegroundColor Cyan
Write-Host "====================================" -ForegroundColor Cyan
Write-Host ""

# Remove shortcut from Startup folder
$shortcutPath = Join-Path $STARTUP_FOLDER "$TASK_NAME.lnk"

if (Test-Path $shortcutPath) {
    Remove-Item $shortcutPath -Force
    Write-Host "[OK] Startup shortcut removed: $shortcutPath" -ForegroundColor Green
} else {
    Write-Host "[INFO] No startup shortcut found." -ForegroundColor Yellow
}

# Also try to remove Task Scheduler task (if it exists from previous install)
$existingTask = Get-ScheduledTask -TaskName $TASK_NAME -ErrorAction SilentlyContinue

if ($existingTask) {
    try {
        Unregister-ScheduledTask -TaskName $TASK_NAME -Confirm:$false
        Write-Host "[OK] Scheduled task '$TASK_NAME' removed successfully!" -ForegroundColor Green
    } catch {
        Write-Host "[INFO] Could not remove scheduled task (may require admin)" -ForegroundColor Yellow
    }
}

Write-Host ""
Write-Host "QwenClaw will no longer start automatically with Windows." -ForegroundColor Yellow
Write-Host "You can still start it manually with: bun run start" -ForegroundColor Cyan
