park_relay.cmd: resolve a real interpreter -- a second admin account has NO working python
Setting up remote access exposed this: 'python' works for the operator's own account only. It resolves through pyenv SHIMS driven by PYENV/PYENV_HOME/ PYENV_ROOT, and all three are USER-scoped to that account; the single machine-wide PATH entry points at a Python39-32 folder that no longer exists. So a dedicated remote-admin login (the account just created for SSH/RDP) gets NO python at all -- parking the relay from the road would have failed with 'python is not recognized', at night, with players waiting. park_relay.cmd now resolves an interpreter explicitly and prints which one: BT_PYTHON override -> the project's pyenv 3.11.4 (calling account's profile, then the operator's -- Administrators can read it) -> the machine-wide py launcher -> whatever is on PATH -> a clear error naming the fix. Verified both as the operator and with a simulated second-account environment (machine PATH only, PYENV cleared): both resolve 3.11.4. Also dropped a delayed-expansion bug in the first cut (!CAND! without EnableDelayedExpansion would have silently evaluated to nothing). Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Opus 5
parent
05fdd319d6
commit
6b0402badc
@@ -144,7 +144,14 @@ rotating the old log to `content\parked_relay.log.1` so you can still see what h
|
||||
the window (or Ctrl-C) stops the relay for good. To have it come back after a reboot, put a
|
||||
*shortcut* to `park_relay.cmd` in your Startup folder (Win+R → `shell:startup`) — no admin needed.
|
||||
|
||||
Leave it running. Note the port it prints for operator control (**1507** = console port + 7) and
|
||||
Leave it running.
|
||||
|
||||
> **If you log in from a second account** (a dedicated remote-admin login over SSH/RDP), always
|
||||
> park the relay with `park_relay.cmd` rather than typing `python ...` yourself. `python` only
|
||||
> works for the main account here — it resolves through pyenv shims driven by `PYENV*` variables
|
||||
> that are scoped to that user, and the one machine-wide Python entry points at a folder that no
|
||||
> longer exists. The `.cmd` finds a real interpreter explicitly and prints which one it used;
|
||||
> a bare `python` command from the other account just says "not recognized". Note the port it prints for operator control (**1507** = console port + 7) and
|
||||
copy `content\operator_secret.txt` — that string is what any console needs to connect, and it grants
|
||||
full mission control, so hand it out deliberately.
|
||||
|
||||
|
||||
+48
-1
@@ -8,10 +8,57 @@ REM itself after a reboot. No admin rights needed either way.
|
||||
REM
|
||||
REM The window stays open: it is the supervisor. Closing it (or Ctrl-C)
|
||||
REM stops the relay for good.
|
||||
REM
|
||||
REM WHY THIS HUNTS FOR AN INTERPRETER INSTEAD OF JUST SAYING "python"
|
||||
REM (2026-07-26): on the operator's machine `python` resolves through
|
||||
REM pyenv SHIMS that need PYENV/PYENV_HOME/PYENV_ROOT -- and those are
|
||||
REM USER-scoped to the operator's own account. A second account (e.g. a
|
||||
REM dedicated remote-admin login over SSH/RDP) gets NO working python at
|
||||
REM all: the one machine-wide PATH entry points at a Python39-32 folder
|
||||
REM that no longer exists. Parking the relay would then fail with
|
||||
REM "python is not recognized" -- from the road, at night, with players
|
||||
REM waiting. So: resolve a real interpreter explicitly, and say which.
|
||||
REM ===================================================================
|
||||
setlocal
|
||||
title BattleTech relay (parked)
|
||||
cd /d "%~dp0.."
|
||||
python "tools\btrelay_park.py" %*
|
||||
|
||||
set "BTPY="
|
||||
|
||||
REM 1. explicit override always wins
|
||||
if defined BT_PYTHON if exist "%BT_PYTHON%" set "BTPY=%BT_PYTHON%"
|
||||
|
||||
REM 2. the interpreter this project is developed against (has PySide6).
|
||||
REM Check the CALLING account's profile first, then the operator's --
|
||||
REM a second admin account can read it (Administrators has access).
|
||||
if not defined BTPY if exist "%USERPROFILE%\.pyenv\pyenv-win\versions\3.11.4\python.exe" set "BTPY=%USERPROFILE%\.pyenv\pyenv-win\versions\3.11.4\python.exe"
|
||||
if not defined BTPY if exist "C:\Users\epilectrik\.pyenv\pyenv-win\versions\3.11.4\python.exe" set "BTPY=C:\Users\epilectrik\.pyenv\pyenv-win\versions\3.11.4\python.exe"
|
||||
|
||||
REM 3. the machine-wide launcher (works for ANY account)
|
||||
if not defined BTPY (
|
||||
if exist "C:\Windows\py.exe" set "BTPY=C:\Windows\py.exe -3"
|
||||
)
|
||||
|
||||
REM 4. whatever is on PATH, if anything
|
||||
if not defined BTPY (
|
||||
for /f "delims=" %%P in ('where python 2^>nul') do (
|
||||
if not defined BTPY set "BTPY=%%P"
|
||||
)
|
||||
)
|
||||
|
||||
if not defined BTPY (
|
||||
echo.
|
||||
echo ERROR: no Python interpreter found.
|
||||
echo.
|
||||
echo Set BT_PYTHON to a python.exe and run this again, e.g.:
|
||||
echo set "BT_PYTHON=C:\Users\epilectrik\.pyenv\pyenv-win\versions\3.11.4\python.exe"
|
||||
echo.
|
||||
pause
|
||||
exit /b 1
|
||||
)
|
||||
|
||||
echo Using interpreter: %BTPY%
|
||||
%BTPY% "tools\btrelay_park.py" %*
|
||||
echo.
|
||||
echo The parked relay has stopped.
|
||||
pause
|
||||
|
||||
Reference in New Issue
Block a user