autostart-run.bat did 'cd /d %~dp0' -> scripts/, but web-vnc.exe/webvnc.conf/ go.mod live in the repo root, so the binary was never found and web-vnc never started after reboot. Now it cd's to %~dp0.. (repo root). The task was ONSTART/RU SYSTEM (session 0) so it could not show a window, making failures invisible. install-autostart.bat now registers ONLOGON /RL HIGHEST as the current user -> a visible console opens at logon. autostart-run.bat sets a window title, prints status, stays open while web-vnc serves, and pauses on fatal errors (no binary / no webvnc.conf) so the reason is visible. Docs updated.
58 lines
1.8 KiB
Batchfile
58 lines
1.8 KiB
Batchfile
@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 was created elevated), 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 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 |