$ErrorActionPreference = "Stop"

Get-Process -Name "Index" -ErrorAction SilentlyContinue | Stop-Process -Force
$installDirectory = Join-Path $env:LOCALAPPDATA "Programs\Index"
$startMenuShortcut = Join-Path $env:APPDATA "Microsoft\Windows\Start Menu\Programs\Index.lnk"
$desktopShortcut = Join-Path ([Environment]::GetFolderPath("Desktop")) "Index.lnk"

Remove-Item -LiteralPath $startMenuShortcut -Force -ErrorAction SilentlyContinue
Remove-Item -LiteralPath $desktopShortcut -Force -ErrorAction SilentlyContinue
Remove-Item -LiteralPath $installDirectory -Recurse -Force -ErrorAction SilentlyContinue

Write-Host "Index was removed. Your local queued captures remain in Local AppData unless you delete them manually."
