Translate run.bat and open-firewall.bat to English ASCII
Convert the .bat scripts from Russian (UTF-8 with BOM + chcp 65001) to plain English ASCII without BOM/chcp, so they render correctly under any OEM console codepage without relying on BOM handling.
This commit is contained in:
@@ -1,44 +1,43 @@
|
|||||||
@echo off
|
@echo off
|
||||||
REM ============================================================
|
REM ============================================================
|
||||||
REM web-vnc launcher - запуск в один клик. Спрашивает только пароль.
|
REM web-vnc launcher - one-click start, asks only for the password.
|
||||||
REM ============================================================
|
REM ============================================================
|
||||||
chcp 65001 >nul
|
|
||||||
cd /d "%~dp0"
|
cd /d "%~dp0"
|
||||||
|
|
||||||
echo.
|
echo.
|
||||||
echo === web-vnc: VNC в браузере ===
|
echo === web-vnc: VNC in the browser ===
|
||||||
echo.
|
echo.
|
||||||
|
|
||||||
REM --- 1. Бинарник ---
|
REM --- 1. Binary ---
|
||||||
if exist "web-vnc.exe" goto havebin
|
if exist "web-vnc.exe" goto havebin
|
||||||
where go >nul 2>nul
|
where go >nul 2>nul
|
||||||
if not errorlevel 1 goto dogobuild
|
if not errorlevel 1 goto dogobuild
|
||||||
echo [ошибка] web-vnc.exe не найден, а Go не установлен.
|
echo [error] web-vnc.exe not found and Go is not installed.
|
||||||
echo Установите Go с https://go.dev/dl/ либо положите собранный web-vnc.exe рядом.
|
echo Install Go from https://go.dev/dl/ or place a built web-vnc.exe next to this script.
|
||||||
echo.
|
echo.
|
||||||
pause
|
pause
|
||||||
exit /b 1
|
exit /b 1
|
||||||
:dogobuild
|
:dogobuild
|
||||||
echo Собираю web-vnc.exe ...
|
echo Building web-vnc.exe ...
|
||||||
go build -o web-vnc.exe .\cmd\web-vnc
|
go build -o web-vnc.exe .\cmd\web-vnc
|
||||||
if errorlevel 1 goto buildfail
|
if errorlevel 1 goto buildfail
|
||||||
:havebin
|
:havebin
|
||||||
|
|
||||||
REM --- 2. noVNC-клиент ---
|
REM --- 2. noVNC client ---
|
||||||
if exist "internal\server\static\core\rfb.js" goto havenovnc
|
if exist "internal\server\static\core\rfb.js" goto havenovnc
|
||||||
echo noVNC-клиент ещё не встроен. Пытаюсь скачать ...
|
echo noVNC client is not bundled yet. Trying to download ...
|
||||||
powershell -NoProfile -ExecutionPolicy Bypass -File "%~dp0scripts\get-novnc.ps1"
|
powershell -NoProfile -ExecutionPolicy Bypass -File "%~dp0scripts\get-novnc.ps1"
|
||||||
if errorlevel 1 goto novncfail
|
if errorlevel 1 goto novncfail
|
||||||
echo Пересобираю с noVNC ...
|
echo Rebuilding with noVNC ...
|
||||||
go build -o web-vnc.exe .\cmd\web-vnc
|
go build -o web-vnc.exe .\cmd\web-vnc
|
||||||
goto havenovnc
|
goto havenovnc
|
||||||
:novncfail
|
:novncfail
|
||||||
echo [предупреждение] Не удалось скачать noVNC (нет интернета?).
|
echo [warning] Could not download noVNC (no internet?).
|
||||||
echo В браузере откроется страница с подсказкой. Повторите позже: scripts\get-novnc.ps1
|
echo The browser will open a page with a hint. Retry later: scripts\get-novnc.ps1
|
||||||
echo.
|
echo.
|
||||||
:havenovnc
|
:havenovnc
|
||||||
|
|
||||||
REM --- 3. VNC-сервер (поиск/загрузка) ---
|
REM --- 3. VNC server (find/download) ---
|
||||||
set "SPAWNARGS="
|
set "SPAWNARGS="
|
||||||
set "SPAWN_CMD="
|
set "SPAWN_CMD="
|
||||||
if exist "vnc\winvnc.exe" goto uselocalvnc
|
if exist "vnc\winvnc.exe" goto uselocalvnc
|
||||||
@@ -49,7 +48,7 @@ if exist "C:\Program Files\uvnc bvba\UltraVNC\winvnc.exe" goto autodetectvnc
|
|||||||
if exist "C:\Program Files (x86)\uvnc bvba\UltraVNC\winvnc.exe" goto autodetectvnc
|
if exist "C:\Program Files (x86)\uvnc bvba\UltraVNC\winvnc.exe" goto autodetectvnc
|
||||||
if exist "C:\Program Files\TightVNC\tvnserver.exe" goto autodetectvnc
|
if exist "C:\Program Files\TightVNC\tvnserver.exe" goto autodetectvnc
|
||||||
if exist "C:\Program Files (x86)\TightVNC\tvnserver.exe" goto autodetectvnc
|
if exist "C:\Program Files (x86)\TightVNC\tvnserver.exe" goto autodetectvnc
|
||||||
echo VNC-сервер не найден. Пытаюсь скачать портативный UltraVNC ...
|
echo VNC server not found. Trying to download a portable UltraVNC ...
|
||||||
powershell -NoProfile -ExecutionPolicy Bypass -File "%~dp0scripts\get-vnc.ps1"
|
powershell -NoProfile -ExecutionPolicy Bypass -File "%~dp0scripts\get-vnc.ps1"
|
||||||
if errorlevel 1 goto novncserver
|
if errorlevel 1 goto novncserver
|
||||||
if exist "vnc\winvnc.exe" goto uselocalvnc
|
if exist "vnc\winvnc.exe" goto uselocalvnc
|
||||||
@@ -59,75 +58,75 @@ goto novncserver
|
|||||||
if exist "vnc\winvnc.exe" set "SPAWN_CMD=vnc\winvnc.exe -run"
|
if exist "vnc\winvnc.exe" set "SPAWN_CMD=vnc\winvnc.exe -run"
|
||||||
if exist "vnc\tvnserver.exe" if not defined SPAWN_CMD set "SPAWN_CMD=vnc\tvnserver.exe -run"
|
if exist "vnc\tvnserver.exe" if not defined SPAWN_CMD set "SPAWN_CMD=vnc\tvnserver.exe -run"
|
||||||
set "SPAWNARGS=--spawn-command "%SPAWN_CMD%""
|
set "SPAWNARGS=--spawn-command "%SPAWN_CMD%""
|
||||||
echo Найден локальный VNC-сервер: %SPAWN_CMD%
|
echo Found local VNC server: %SPAWN_CMD%
|
||||||
goto vncdone
|
goto vncdone
|
||||||
:autodetectvnc
|
:autodetectvnc
|
||||||
echo VNC-сервер найден в системе (авто-определение при запуске).
|
echo VNC server found in the system (auto-detection on start).
|
||||||
goto vncdone
|
goto vncdone
|
||||||
:novncserver
|
:novncserver
|
||||||
echo [предупреждение] VNC-сервер не удалось получить.
|
echo [warning] Could not get a VNC server.
|
||||||
echo Без VNC-сервера рабочий стол не будет транслироваться.
|
echo Without a VNC server the desktop will not be streamed.
|
||||||
echo Установите UltraVNC/TightVNC вручную или повторите: scripts\get-vnc.ps1
|
echo Install UltraVNC/TightVNC manually or retry: scripts\get-vnc.ps1
|
||||||
echo.
|
echo.
|
||||||
:vncdone
|
:vncdone
|
||||||
|
|
||||||
REM --- 4. Пароль ---
|
REM --- 4. Password ---
|
||||||
:getpw
|
:getpw
|
||||||
set "PW="
|
set "PW="
|
||||||
set /p "PW=Введите пароль доступа: "
|
set /p "PW=Enter access password: "
|
||||||
if "%PW%"=="" goto emptypw
|
if "%PW%"=="" goto emptypw
|
||||||
goto gotpw
|
goto gotpw
|
||||||
:emptypw
|
:emptypw
|
||||||
echo Пароль не может быть пустым.
|
echo Password cannot be empty.
|
||||||
goto getpw
|
goto getpw
|
||||||
:gotpw
|
:gotpw
|
||||||
|
|
||||||
REM --- 4b. Sync UltraVNC password with the one entered (only when it differs) ---
|
REM --- 4b. Sync UltraVNC password with the one entered (only when it differs) ---
|
||||||
echo Синхронизирую пароль UltraVNC с введённым. При несовпадении запросит права администратора...
|
echo Syncing UltraVNC password with the one entered. It will ask for admin rights if they differ...
|
||||||
powershell -NoProfile -ExecutionPolicy Bypass -File "%~dp0scripts\ensure-vnc-password.ps1" -Password "%PW%"
|
powershell -NoProfile -ExecutionPolicy Bypass -File "%~dp0scripts\ensure-vnc-password.ps1" -Password "%PW%"
|
||||||
if errorlevel 1 echo [предупреждение] Не удалось синхронизировать пароль UltraVNC - продолжаю.
|
if errorlevel 1 echo [warning] Could not sync the UltraVNC password - continuing.
|
||||||
|
|
||||||
REM --- 5. Хэш пароля + тот же пароль для VNC-сервера ---
|
REM --- 5. Password hash + same password for the VNC server ---
|
||||||
echo Генерирую хэш пароля ...
|
echo Generating password hash ...
|
||||||
for /f "delims=" %%i in ('web-vnc.exe --gen-hash "%PW%"') do set "HASH=%%i"
|
for /f "delims=" %%i in ('web-vnc.exe --gen-hash "%PW%"') do set "HASH=%%i"
|
||||||
if "%HASH%"=="" goto hashfail
|
if "%HASH%"=="" goto hashfail
|
||||||
REM Тот же пароль будет автоматически передан noVNC для авторизации на VNC-сервере.
|
REM The same password is auto-sent to noVNC to authenticate against the VNC server.
|
||||||
set "WEBVNC_VNC_PASSWORD=%PW%"
|
set "WEBVNC_VNC_PASSWORD=%PW%"
|
||||||
set "PW="
|
set "PW="
|
||||||
|
|
||||||
REM --- 6. Доступные адреса ---
|
REM --- 6. Available addresses ---
|
||||||
echo.
|
echo.
|
||||||
echo === Адреса для подключения (порт 8080) ===
|
echo === Addresses to connect to (port 8080) ===
|
||||||
echo http://localhost:8080
|
echo http://localhost:8080
|
||||||
for /f "delims=" %%a in ('powershell -NoProfile -ExecutionPolicy Bypass -File "%~dp0scripts\list-ips.ps1"') do echo http://%%a:8080
|
for /f "delims=" %%a in ('powershell -NoProfile -ExecutionPolicy Bypass -File "%~dp0scripts\list-ips.ps1"') do echo http://%%a:8080
|
||||||
echo.
|
echo.
|
||||||
echo Если с другой машины не открывается - один раз выполните от имени
|
echo If it does not open from another machine, run once as administrator:
|
||||||
echo администратора: scripts\open-firewall.bat
|
echo scripts\open-firewall.bat
|
||||||
echo.
|
echo.
|
||||||
|
|
||||||
REM --- 7. Запуск ---
|
REM --- 7. Launch ---
|
||||||
echo Запускаю web-vnc на http://localhost:8080
|
echo Starting web-vnc on http://localhost:8080
|
||||||
echo Остановить: Ctrl+C
|
echo Stop: Ctrl+C
|
||||||
echo.
|
echo.
|
||||||
REM --- 6b. 5900 already listening? -> do NOT spawn a 2nd VNC server (avoid conflict with the UltraVNC service) ---
|
REM --- 6b. 5900 already listening? -> do NOT spawn a 2nd VNC server (avoid conflict with the UltraVNC service) ---
|
||||||
set "SPAWNFLAG=--spawn"
|
set "SPAWNFLAG=--spawn"
|
||||||
powershell -NoProfile -Command "try{$c=New-Object Net.Sockets.TcpClient('127.0.0.1',5900);$c.Close();exit 0}catch{exit 1}"
|
powershell -NoProfile -Command "try{$c=New-Object Net.Sockets.TcpClient('127.0.0.1',5900);$c.Close();exit 0}catch{exit 1}"
|
||||||
if not errorlevel 1 (
|
if not errorlevel 1 (
|
||||||
echo VNC-сервер уже слушает 127.0.0.1:5900 - подключаюсь к нему без --spawn.
|
echo VNC server already listening on 127.0.0.1:5900 - connecting to it without --spawn.
|
||||||
set "SPAWNFLAG="
|
set "SPAWNFLAG="
|
||||||
)
|
)
|
||||||
web-vnc.exe --password-hash "%HASH%" %SPAWNARGS% %SPAWNFLAG% --listen :8080
|
web-vnc.exe --password-hash "%HASH%" %SPAWNARGS% %SPAWNFLAG% --listen :8080
|
||||||
echo.
|
echo.
|
||||||
echo Сервер остановлен.
|
echo Server stopped.
|
||||||
pause
|
pause
|
||||||
exit /b
|
exit /b
|
||||||
|
|
||||||
:buildfail
|
:buildfail
|
||||||
echo Сборка не удалась.
|
echo Build failed.
|
||||||
pause
|
pause
|
||||||
exit /b 1
|
exit /b 1
|
||||||
|
|
||||||
:hashfail
|
:hashfail
|
||||||
echo [ошибка] Не удалось сгенерировать хэш пароля.
|
echo [error] Could not generate the password hash.
|
||||||
pause
|
pause
|
||||||
exit /b 1
|
exit /b 1
|
||||||
+12
-13
@@ -1,16 +1,15 @@
|
|||||||
@echo off
|
@echo off
|
||||||
REM ============================================================
|
REM ============================================================
|
||||||
REM open-firewall.bat - открывает порт 8080 в Windows Firewall.
|
REM open-firewall.bat - opens port 8080 in the Windows Firewall.
|
||||||
REM Запускать от имени администратора (один раз).
|
REM Run as administrator (once). Or just launch it: it will request
|
||||||
REM Либо запустите дважды: файл сам запросит права администратора.
|
REM admin rights itself.
|
||||||
REM ============================================================
|
REM ============================================================
|
||||||
chcp 65001 >nul
|
|
||||||
cd /d "%~dp0"
|
cd /d "%~dp0"
|
||||||
|
|
||||||
REM Проверка прав администратора и авто-повышение.
|
REM Admin check + auto-elevate.
|
||||||
net session >nul 2>nul
|
net session >nul 2>nul
|
||||||
if errorlevel 1 (
|
if errorlevel 1 (
|
||||||
echo Запрос прав администратора ...
|
echo Requesting administrator rights ...
|
||||||
powershell -Command "Start-Process -FilePath '%~f0' -Verb RunAs"
|
powershell -Command "Start-Process -FilePath '%~f0' -Verb RunAs"
|
||||||
exit /b
|
exit /b
|
||||||
)
|
)
|
||||||
@@ -18,20 +17,20 @@ if errorlevel 1 (
|
|||||||
set PORT=8080
|
set PORT=8080
|
||||||
set RULE=web-vnc
|
set RULE=web-vnc
|
||||||
|
|
||||||
echo Удаляю старое правило (если есть) ...
|
echo Removing the old rule (if any) ...
|
||||||
netsh advfirewall firewall delete rule name="%RULE%" >nul 2>nul
|
netsh advfirewall firewall delete rule name="%RULE%" >nul 2>nul
|
||||||
|
|
||||||
echo Добавляю разрешающее правило для входящего TCP-трафика на порт %PORT% ...
|
echo Adding an allow rule for inbound TCP traffic on port %PORT% ...
|
||||||
netsh advfirewall firewall add rule name="%RULE%" dir=in action=allow protocol=TCP localport=%PORT%
|
netsh advfirewall firewall add rule name="%RULE%" dir=in action=allow protocol=TCP localport=%PORT%
|
||||||
if errorlevel 1 (
|
if errorlevel 1 (
|
||||||
echo [ошибка] Не удалось добавить правило.
|
echo [error] Could not add the rule.
|
||||||
pause
|
pause
|
||||||
exit /b 1
|
exit /b 1
|
||||||
)
|
)
|
||||||
|
|
||||||
echo.
|
echo.
|
||||||
echo Готово. Порт %PORT% открыт для входящих подключений.
|
echo Done. Port %PORT% is open for inbound connections.
|
||||||
echo Теперь к web-vnc можно подключаться с других машин сети по адресу:
|
echo You can now connect to web-vnc from other machines on the network at:
|
||||||
echo http://IP_ЭТОЙ_МАШИНЫ:%PORT%
|
echo http://THIS_MACHINE_IP:%PORT%
|
||||||
echo.
|
echo.
|
||||||
pause
|
pause
|
||||||
Reference in New Issue
Block a user