$ErrorActionPreference = "SilentlyContinue" Write-Host "=== Cleanup Tailscale-Custom ===" -ForegroundColor Cyan # 1. Kill tray process Write-Host "Killing tray process..." -ForegroundColor Yellow Get-Process "tailscale-tray" | Stop-Process -Force Start-Sleep -Milliseconds 500 # 2. Stop and delete service Write-Host "Stopping service..." -ForegroundColor Yellow Stop-Service "Tailscale-Custom" -Force Start-Sleep -Seconds 2 sc.exe delete "Tailscale-Custom" | Out-Null Write-Host "Service deleted." -ForegroundColor Green # 3. Kill remaining processes Get-Process "tailscaled","tailscale" | Stop-Process -Force Start-Sleep -Milliseconds 500 # 4. Remove Program Files $installDir = "C:\Program Files\Tailscale-Custom" if (Test-Path $installDir) { Remove-Item $installDir -Recurse -Force Write-Host "Removed: $installDir" -ForegroundColor Green } # 5. Remove ProgramData (state, logs, socket) $dataDir = "$env:ProgramData\Tailscale-Custom" if (Test-Path $dataDir) { Remove-Item $dataDir -Recurse -Force Write-Host "Removed: $dataDir" -ForegroundColor Green } # 6. Remove LocalAppData $localDir = "$env:LOCALAPPDATA\Tailscale-Custom" if (Test-Path $localDir) { Remove-Item $localDir -Recurse -Force Write-Host "Removed: $localDir" -ForegroundColor Green } # 7. Remove registry keys $regPaths = @( "HKLM:\SYSTEM\CurrentControlSet\Services\Tailscale-Custom", "HKLM:\SOFTWARE\Tailscale-Custom", "HKCU:\SOFTWARE\Tailscale-Custom" ) foreach ($reg in $regPaths) { if (Test-Path $reg) { Remove-Item $reg -Recurse -Force Write-Host "Removed registry: $reg" -ForegroundColor Green } } # 8. Verify Write-Host "`n=== Verification ===" -ForegroundColor Cyan $svc = Get-Service "Tailscale-Custom" -ErrorAction SilentlyContinue if ($svc) { Write-Host "WARNING: Service still exists!" -ForegroundColor Red } else { Write-Host "Service: removed" -ForegroundColor Green } if (Test-Path $installDir) { Write-Host "WARNING: $installDir still exists!" -ForegroundColor Red } else { Write-Host "Program Files: removed" -ForegroundColor Green } if (Test-Path $dataDir) { Write-Host "WARNING: $dataDir still exists!" -ForegroundColor Red } else { Write-Host "ProgramData: removed" -ForegroundColor Green } Write-Host "`nDone! Press any key..." -ForegroundColor Cyan $null = $Host.UI.RawUI.ReadKey("NoEcho,IncludeKeyDown")