@echo off REM ============================================================ REM install-autostart.bat - register web-vnc as a startup task. REM Creates a scheduled task "web-vnc" that runs at YOUR logon REM (as the current user, with highest privileges available to REM you) and opens a VISIBLE console window running REM scripts\autostart-run.bat. The console stays open while REM web-vnc serves, and pauses on error so you can see why it REM did not start. REM REM Why logon (not boot/SYSTEM): a task that runs as SYSTEM at REM boot runs in session 0 and CANNOT show a window on your REM desktop, so you would never see its output. Running at your REM logon, in your session, makes the console visible. (If you REM need it before any user logs in, that requires the hidden REM SYSTEM/boot variant - which is invisible by design.) 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%" (at logon, current user, highest, visible) ... schtasks /Create /TN "%TASK%" /TR "cmd /c \"%CMD%\"" /SC ONLOGON /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 when you log in: a console echo window will open and stay while it serves. Close that window to stop it. echo Start it now (without re-logging-in): echo schtasks /Run /TN "%TASK%" echo Remove it with: uninstall-autostart.bat echo. pause