param([switch]$Required)

$candidates = @(
    @(
        (Join-Path $env:ProgramFiles 'obs-studio\bin\64bit\obs64.exe'),
        (Join-Path ${env:ProgramFiles(x86)} 'obs-studio\bin\64bit\obs64.exe'),
        'D:\Programme\obs-studio\bin\64bit\obs64.exe'
    ) | Where-Object { $_ -and (Test-Path $_) }
)

if ($candidates) {
    $candidates[0]
    return
}

if ($Required) {
    throw 'OBS Studio wurde nicht gefunden. Starte tools\Install-PilotNG.ps1 erneut.'
}
