Скрипт брандмауэра: ASCII и CRLF, иначе cmd.exe рвёт файл на куски
cmd не понимает LF-переводы строк и UTF-8 кириллицу: строки исполнялись фрагментами. Теперь файл ASCII+CRLF, а сборка проверяет и приводит к нужному виду.
This commit is contained in:
1 parent
8ee96110a1
commit
fcdb0375ba
3 files changed
+38
-20
No files matched your search
+15
-15
@@ -1,10 +1,9 @@
|
||||
@echo off
|
||||
setlocal
|
||||
chcp 65001 >nul
|
||||
title Quiz: allow network access
|
||||
|
||||
rem Скобки и вложенные блоки в cmd ломаются, поэтому только goto и однострочные
|
||||
rem команды. Имена правил без скобок — их тоже парсит интерпретатор.
|
||||
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
|
||||
@@ -12,7 +11,8 @@ goto work
|
||||
|
||||
:elevate
|
||||
echo.
|
||||
echo Нужны права администратора. Сейчас Windows покажет запрос — нажмите "Да".
|
||||
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
|
||||
|
||||
@@ -20,38 +20,38 @@ exit /b
|
||||
set "FOLDER=%~dp0"
|
||||
set "RULE_APP=Quiz Server app"
|
||||
set "RULE_PORT=Quiz Server port 3000"
|
||||
set "RULE_DEV=Quiz Server port 5173"
|
||||
set "RULE_DEV=Quiz Server dev port 5173"
|
||||
|
||||
echo.
|
||||
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 [!] не удалось разрешить quiz.exe
|
||||
if not errorlevel 1 echo [ok] quiz.exe разрешён
|
||||
if errorlevel 1 echo [!] could not allow quiz.exe
|
||||
if not errorlevel 1 echo [ok] quiz.exe allowed
|
||||
goto ports
|
||||
|
||||
:noapp
|
||||
echo [--] quiz.exe рядом не найден, пропускаю
|
||||
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 [!] не удалось открыть порт 3000
|
||||
if not errorlevel 1 echo [ok] порт 3000 открыт
|
||||
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 [!] не удалось открыть порт 5173
|
||||
if not errorlevel 1 echo [ok] порт 5173 открыт
|
||||
if errorlevel 1 echo [!] could not open port 5173
|
||||
if not errorlevel 1 echo [ok] port 5173 opened
|
||||
|
||||
echo.
|
||||
echo Проверка:
|
||||
echo Result:
|
||||
netsh advfirewall firewall show rule name="%RULE_PORT%"
|
||||
|
||||
echo.
|
||||
echo Готово. Запустите quiz.exe и откройте с телефона адрес из его окна.
|
||||
echo Done. Start quiz.exe and open the address from its window.
|
||||
echo.
|
||||
pause
|
||||
Reference in new issue
Block a user