- set-password.bat: one-time password setup -> writes webvnc.conf (HASH + VNC_PASSWORD), syncs UltraVNC via ensure-vnc-password.ps1; if the 'web-vnc' task is installed, restarts it (elevated) to reload the new password, skipping restart when the password is unchanged. - run.bat: no longer prompts for the password; reads it from webvnc.conf (asks to run set-password.bat first if absent). Also clears --spawn-command (not just --spawn) when 5900 is already listening, to avoid spawning a 2nd VNC server. - scripts/autostart-run.bat: non-interactive launcher for the scheduled task (reads webvnc.conf, finds only a LOCAL VNC server, never downloads at boot). - scripts/install-autostart.bat / uninstall-autostart.bat: register/remove a 'web-vnc' scheduled task (ONSTART, SYSTEM, HIGHEST) via schtasks. - scripts/restart-autostart.bat: restart the task to apply a new password; checks whether web-vnc.exe is running (stop+start, or just start). - .gitignore: ignore webvnc.conf (secret). - AGENTS.md / README.md: document the autostart flow, set-password.bat, the new scripts, and that the running gateway must be restarted to apply a password change.
48 lines
1.4 KiB
Batchfile
48 lines
1.4 KiB
Batchfile
@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 |