@echo off
setlocal
title NaviSwitcher Setup

rem  WHY THIS FILE EXISTS
rem  A .exe downloaded by a browser carries the "mark of the web" (the
rem  Zone.Identifier stream), so SmartScreen greets the user with "Windows
rem  protected your PC" and some people stop right there. This script fetches
rem  the installer itself, strips the mark and launches it - no SmartScreen
rem  prompt. Same trick as in Navigator Connect.
rem
rem  ASCII ONLY - NO NON-ENGLISH TEXT, NO "chcp" IN THIS FILE.
rem  cmd.exe reads a batch file by byte offsets WHILE it runs it. A "chcp" in
rem  the middle makes it re-decode the rest of the file at the old offsets and
rem  the interpreter loses sync: on 2026-08-01 that produced garbage such as
rem  'utionPolicy' is not recognized (the tail of -ExecutionPolicy) and the
rem  installer never started. Plain ASCII with no code-page switching is the
rem  only thing that behaves the same on every Windows locale.

set "URL=https://naviutils.com/NaviSwitcher-Setup.exe"
set "DST=%TEMP%\NaviSwitcher-Setup.exe"

echo.
echo   Downloading NaviSwitcher...
echo.

rem curl.exe ships with Windows 10 1803 and newer; older systems fall back to
rem PowerShell. The PowerShell call stays on ONE line: a caret continuation is
rem exactly what the desync above chopped in half.
curl.exe -fL --progress-bar "%URL%" -o "%DST%"
if errorlevel 1 (
  echo   curl failed, trying PowerShell...
  powershell -NoProfile -ExecutionPolicy Bypass -Command "try { Invoke-WebRequest -Uri '%URL%' -OutFile '%DST%' -UseBasicParsing } catch { exit 1 }"
)

if not exist "%DST%" (
  echo.
  echo   Could not download the installer. Please check your connection
  echo   or download the file manually: %URL%
  echo.
  pause
  exit /b 1
)

rem Strip the mark of the web two ways: the Zone.Identifier stream goes with a
rem plain del, and Unblock-File covers the case where the mark sits elsewhere.
del "%DST%:Zone.Identifier" >nul 2>&1
powershell -NoProfile -Command "Unblock-File -LiteralPath '%DST%'" >nul 2>&1

echo   Starting the installer...
start "" "%DST%"
exit /b 0
