fix(autostart): run from repo root + visible console at logon
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.
This commit is contained in:
+18
-7
@@ -1,9 +1,19 @@
|
||||
@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 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 ============================================================
|
||||
@@ -31,8 +41,8 @@ if not exist "scripts\autostart-run.bat" (
|
||||
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
|
||||
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
|
||||
@@ -40,8 +50,9 @@ if errorlevel 1 (
|
||||
)
|
||||
|
||||
echo.
|
||||
echo Done. web-vnc will start automatically on every boot.
|
||||
echo Start it now (without rebooting):
|
||||
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.
|
||||
|
||||
Reference in New Issue
Block a user