@echo off
rem linr for Windows: double click this file to install linr (the helper that reads your players, and the app:
rem the tab on the taskbar, the icon by the clock, the panel, the toast and the player window).
rem
rem It needs nothing else installed. It uses Windows PowerShell and the C# compiler that are part of
rem Windows 10 and 11. It downloads install-windows.ps1 from https://getlinr.com/download/ and runs it.
rem
rem About the warning you may see: this file and the scripts are not code signed yet, so Windows SmartScreen
rem can show "Windows protected your PC" the first time. Click "More info", then "Run anyway". The scripts run
rem with -ExecutionPolicy Bypass only for themselves; your system settings are not changed.

setlocal
set "LINR_NO_PAUSE=1"
title linr for Windows
cd /d "%~dp0"

set "PS=%SystemRoot%\System32\WindowsPowerShell\v1.0\powershell.exe"
if not exist "%PS%" set "PS=powershell.exe"

set "PS1=%~dp0install-windows.ps1"
if exist "%PS1%" goto run

set "PS1=%TEMP%\install-windows.ps1"
echo   Downloading linr from getlinr.com ...
"%PS%" -NoProfile -ExecutionPolicy Bypass -Command "$ProgressPreference = 'SilentlyContinue'; [Net.ServicePointManager]::SecurityProtocol = [Net.ServicePointManager]::SecurityProtocol -bor 3072; Invoke-WebRequest -UseBasicParsing -Uri 'https://getlinr.com/download/install-windows.ps1' -OutFile (Join-Path $env:TEMP 'install-windows.ps1')"
if errorlevel 1 goto downloadfailed
if not exist "%PS1%" goto downloadfailed

:run
"%PS%" -NoProfile -ExecutionPolicy Bypass -File "%PS1%"
echo.
echo   You can close this window.
echo.
pause
exit /b 0

:downloadfailed
echo.
echo   The download did not work. Check your internet connection and try again.
echo.
pause
exit /b 1
