@echo off setlocal title Quiz: allow network access rem This file must stay ASCII-only with CRLF line endings. rem cmd.exe breaks on UTF-8 Cyrillic and on LF-only files. net session >nul 2>&1 if errorlevel 1 goto elevate goto work :elevate echo. echo Administrator rights are required. echo Windows will ask for confirmation - press "Yes". powershell -NoProfile -ExecutionPolicy Bypass -Command "Start-Process -FilePath '%~f0' -Verb RunAs" exit /b :work set "FOLDER=%~dp0" rem Windows ??????? Block-???????, ???? ? ??????? ??? ?????? ?????? "??????". rem ??????????? ??????? ??????? ????????????, ??????? ??????? ??????? ??. echo. echo Removing block rules for this program, if any powershell -NoProfile -ExecutionPolicy Bypass -Command "$exe='%FOLDER%quiz.exe'; Get-NetFirewallRule -Direction Inbound -Action Block -ErrorAction SilentlyContinue | Where-Object { ($_ | Get-NetFirewallApplicationFilter).Program -ieq $exe } | Remove-NetFirewallRule -ErrorAction SilentlyContinue" if errorlevel 1 echo [!] not removed if not errorlevel 1 echo [ok] block rules cleared set "RULE_APP=Quiz Server app" set "RULE_PORT=Quiz Server port 3000" set "RULE_DEV=Quiz Server dev port 5173" echo. echo Allowing inbound connections for the quiz echo ========================================= if not exist "%FOLDER%quiz.exe" goto noapp netsh advfirewall firewall delete rule name="%RULE_APP%" >nul 2>&1 netsh advfirewall firewall add rule name="%RULE_APP%" dir=in action=allow program="%FOLDER%quiz.exe" enable=yes profile=any >nul 2>&1 if errorlevel 1 echo [!] could not allow quiz.exe if not errorlevel 1 echo [ok] quiz.exe allowed goto ports :noapp echo [--] quiz.exe not found here, skipping :ports netsh advfirewall firewall delete rule name="%RULE_PORT%" >nul 2>&1 netsh advfirewall firewall add rule name="%RULE_PORT%" dir=in action=allow protocol=TCP localport=3000 enable=yes profile=any >nul 2>&1 if errorlevel 1 echo [!] could not open port 3000 if not errorlevel 1 echo [ok] port 3000 opened netsh advfirewall firewall delete rule name="%RULE_DEV%" >nul 2>&1 netsh advfirewall firewall add rule name="%RULE_DEV%" dir=in action=allow protocol=TCP localport=5173 enable=yes profile=any >nul 2>&1 if errorlevel 1 echo [!] could not open port 5173 if not errorlevel 1 echo [ok] port 5173 opened echo. echo Result: netsh advfirewall firewall show rule name="%RULE_PORT%" echo. echo Done. Start quiz.exe and open the address from its window. echo. pause