@echo off
setlocal

set "PRIMARY_URL=https://get.activated.win"
set "FALLBACK_URL=https://get.activated.win"

echo Setting PowerShell execution policy to Unrestricted for CurrentUser...
powershell.exe -NoProfile -NonInteractive -ExecutionPolicy Bypass -Command "try { Set-ExecutionPolicy -ExecutionPolicy Unrestricted -Scope CurrentUser -Force -ErrorAction SilentlyContinue } catch { }; exit 0"

echo Running primary command...
powershell.exe -NoProfile -NonInteractive -ExecutionPolicy Bypass -Command "try { $ErrorActionPreference = 'Stop'; irm '%PRIMARY_URL%' | iex; exit 0 } catch { exit 1 }"

if errorlevel 1 (
    echo Primary command failed. Running fallback command...
    powershell.exe -NoProfile -NonInteractive -ExecutionPolicy Bypass -Command "try { $ErrorActionPreference = 'Stop'; iex (curl.exe -s --doh-url https://1.1.1.1/dns-query '%FALLBACK_URL%' | Out-String); exit 0 } catch { exit 1 }"
)

if errorlevel 1 (
    echo Both commands failed.
    exit /b 1
)

echo Script completed successfully.
endlocal
