@echo off setlocal EnableExtensions EnableDelayedExpansion set "FILE=%~1" if "%FILE%"=="" set "FILE=%~dp0links.txt" if not exist "%FILE%" ( echo File not found: %FILE% echo Create it with lines: Name^|https://example.com exit /b 1 ) if "%~2"=="" goto list set "WANT=%~2" set "URL=" for /f "usebackq tokens=1,2 delims=|" %%A in ("%FILE%") do ( if /i "%%A"=="!WANT!" set "URL=%%B" ) if not defined URL ( echo Link not found: !WANT! exit /b 1 ) if /i not "!URL:~0,7!"=="http://" if /i not "!URL:~0,8!"=="https://" ( echo Refusing to open non-http link. exit /b 1 ) start "" "!URL!" exit /b 0 :list set /a N=0 echo Available links: for /f "usebackq tokens=1,2 delims=|" %%A in ("%FILE%") do ( set /a N+=1 echo !N!. %%A - %%B ) exit /b 0