#!/usr/bin/env powershell
# Cleanup and restart Ableton

# Stop Ableton processes
Get-Process 'Ableton Live 12 Suite' -ErrorAction SilentlyContinue | Stop-Process -Force
Get-Process 'AbletonPushCpl' -ErrorAction SilentlyContinue | Stop-Process -Force
Get-Process 'Ableton Index' -ErrorAction SilentlyContinue | Stop-Process -Force
Start-Sleep -Seconds 3

# Remove recovery file
$recoveryFile = 'C:\Users\ren\AppData\Roaming\Ableton\Live 12.0.15\Preferences\CrashRecoveryInfo.cfg'
if (Test-Path $recoveryFile) {
    Remove-Item -LiteralPath $recoveryFile -Force
    Write-Host "Recovery file eliminado"
} else {
    Write-Host "No habia recovery file"
}

# Start Ableton
Start-Process -FilePath 'C:\ProgramData\Ableton\Live 12 Suite\Program\Ableton Live 12 Suite.exe'
Write-Host "Ableton iniciado"
