refactor: move user-facing scripts to repo root; fix set-password ordering

- install-autostart.bat, uninstall-autostart.bat, restart-autostart.bat,
  open-firewall.bat moved from scripts/ to the repo root (next to run.bat and
  set-password.bat). Internal helpers (autostart-run.bat, ensure-vnc-password.ps1,
  get-novnc.*, get-vnc.ps1, list-ips.ps1) stay in scripts/. autostart-run.bat is
  kept in scripts/ because the scheduled task /TR points at it; moving it would
  break already-installed tasks.
- Updated all references (set-password.bat, run.bat, install/restart-autostart.bat,
  AGENTS.md, README.md).
- set-password.bat: write webvnc.conf BEFORE the UltraVNC sync so the web password
  is configured even if ensure-vnc-password.ps1 fails / its UAC is dismissed
  (previously 'Password is not configured' from install-autostart.bat when the
  sync blocked before conf was written).
- AGENTS.md / README.md structure + autostart sections updated for the new layout.
This commit is contained in:
Codex
2026-08-05 15:38:39 +03:00
parent 754f77a8d0
commit 9b8ee94dd5
8 changed files with 64 additions and 50 deletions
-48
View File
@@ -1,48 +0,0 @@
@echo off
REM ============================================================
REM install-autostart.bat - register web-vnc as a startup task.
REM Creates a scheduled task "web-vnc" that runs at system startup
REM (as SYSTEM, highest privileges) and launches
REM scripts\autostart-run.bat in the foreground.
REM Requires administrator rights (auto-elevates).
REM Run set-password.bat first to configure the password.
REM ============================================================
cd /d "%~dp0"
REM Admin check + auto-elevate.
net session >nul 2>nul
if errorlevel 1 (
echo Requesting administrator rights ...
powershell -Command "Start-Process -FilePath '%~f0' -Verb RunAs"
exit /b
)
if not exist "webvnc.conf" (
echo [error] Password is not configured. Run set-password.bat first.
pause
exit /b 1
)
if not exist "scripts\autostart-run.bat" (
echo [error] scripts\autostart-run.bat not found.
pause
exit /b 1
)
set "TASK=web-vnc"
set "CMD=%~dp0scripts\autostart-run.bat"
echo Creating scheduled task "%TASK%" (startup, SYSTEM, highest) ...
schtasks /Create /TN "%TASK%" /TR "cmd /c \"%CMD%\"" /SC ONSTART /RU SYSTEM /RL HIGHEST /F
if errorlevel 1 (
echo [error] Could not create the task.
pause
exit /b 1
)
echo.
echo Done. web-vnc will start automatically on every boot.
echo Start it now (without rebooting):
echo schtasks /Run /TN "%TASK%"
echo Remove it with: scripts\uninstall-autostart.bat
echo.
pause
-36
View File
@@ -1,36 +0,0 @@
@echo off
REM ============================================================
REM open-firewall.bat - opens port 8080 in the Windows Firewall.
REM Run as administrator (once). Or just launch it: it will request
REM admin rights itself.
REM ============================================================
cd /d "%~dp0"
REM Admin check + auto-elevate.
net session >nul 2>nul
if errorlevel 1 (
echo Requesting administrator rights ...
powershell -Command "Start-Process -FilePath '%~f0' -Verb RunAs"
exit /b
)
set PORT=8080
set RULE=web-vnc
echo Removing the old rule (if any) ...
netsh advfirewall firewall delete rule name="%RULE%" >nul 2>nul
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%
if errorlevel 1 (
echo [error] Could not add the rule.
pause
exit /b 1
)
echo.
echo Done. Port %PORT% is open for inbound connections.
echo You can now connect to web-vnc from other machines on the network at:
echo http://THIS_MACHINE_IP:%PORT%
echo.
pause
-58
View File
@@ -1,58 +0,0 @@
@echo off
REM ============================================================
REM restart-autostart.bat - restart the "web-vnc" task so the
REM running gateway reloads webvnc.conf (e.g. after set-password.bat
REM changed the password). web-vnc.exe reads the hash and the VNC
REM password only once at startup, so a restart is the only way to
REM apply a new password to the live gateway.
REM
REM It first checks whether web-vnc.exe is actually running:
REM - running -> stop the task (schtasks /End) and start it again;
REM - not running -> just start it (no /End).
REM Requires administrator rights (the task runs as SYSTEM), so it
REM auto-elevates. Called from set-password.bat, or run manually.
REM ============================================================
cd /d "%~dp0"
net session >nul 2>nul
if errorlevel 1 (
echo Requesting administrator rights ...
powershell -Command "Start-Process -FilePath '%~f0' -Verb RunAs"
exit /b
)
set "TASK=web-vnc"
schtasks /Query /TN "%TASK%" >nul 2>nul
if errorlevel 1 (
echo [error] Task "%TASK%" is not installed. Run scripts\install-autostart.bat first.
pause
exit /b 1
)
REM --- Is web-vnc.exe currently running? ---
set "RUNNING=0"
tasklist /FI "IMAGENAME eq web-vnc.exe" 2>nul | findstr /I /B /C:"web-vnc.exe" >nul
if not errorlevel 1 set "RUNNING=1"
if "%RUNNING%"=="1" (
echo web-vnc.exe is running - restarting task "%TASK%" ...
schtasks /End /TN "%TASK%" >nul 2>nul
REM give the previous process a moment to release port 8080
timeout /t 2 /nobreak >nul
) else (
echo web-vnc.exe is NOT running - just starting task "%TASK%" ...
)
schtasks /Run /TN "%TASK%"
if errorlevel 1 (
echo [error] Could not start the task.
pause
exit /b 1
)
echo.
echo Done. web-vnc reloaded the password from webvnc.conf.
echo Check it at http://localhost:8080
echo.
pause
-26
View File
@@ -1,26 +0,0 @@
@echo off
REM ============================================================
REM uninstall-autostart.bat - remove the web-vnc startup task.
REM Deletes the scheduled task "web-vnc" created by
REM install-autostart.bat. Requires administrator rights
REM (auto-elevates).
REM ============================================================
cd /d "%~dp0"
net session >nul 2>nul
if errorlevel 1 (
echo Requesting administrator rights ...
powershell -Command "Start-Process -FilePath '%~f0' -Verb RunAs"
exit /b
)
set "TASK=web-vnc"
echo Removing scheduled task "%TASK%" ...
schtasks /Delete /TN "%TASK%" /F
if errorlevel 1 (
echo [error] Could not remove the task (maybe it does not exist).
pause
exit /b 1
)
echo Done.
pause