|
| 1 | +@echo off |
| 2 | +REM NodeToCode UE Path Detector (Windows) |
| 3 | +REM Finds Unreal Engine installation and updates AGENTS.md |
| 4 | +REM Uses same Python detection methods as launch_bridge.bat |
| 5 | + |
| 6 | +setlocal EnableDelayedExpansion |
| 7 | + |
| 8 | +REM Get the directory where this script is located |
| 9 | +set "SCRIPT_DIR=%~dp0" |
| 10 | +set "PYTHON_SCRIPT=%SCRIPT_DIR%update_agents_ue_path.py" |
| 11 | + |
| 12 | +REM Check if Python script exists |
| 13 | +if not exist "%PYTHON_SCRIPT%" ( |
| 14 | + echo [detect-ue-path] ERROR: Python script not found at %PYTHON_SCRIPT% |
| 15 | + exit /b 1 |
| 16 | +) |
| 17 | + |
| 18 | +set "PYTHON_EXE=" |
| 19 | + |
| 20 | +REM === Method 1: Check Registry for Launcher-installed UE versions === |
| 21 | +for %%V in (5.7 5.6 5.5 5.4 5.3) do ( |
| 22 | + if "!PYTHON_EXE!"=="" ( |
| 23 | + for /f "tokens=2*" %%A in ('reg query "HKEY_LOCAL_MACHINE\SOFTWARE\EpicGames\Unreal Engine\%%V" /v InstalledDirectory 2^>nul') do ( |
| 24 | + set "UE_DIR=%%B" |
| 25 | + if exist "!UE_DIR!\Engine\Binaries\ThirdParty\Python3\Win64\python.exe" ( |
| 26 | + set "PYTHON_EXE=!UE_DIR!\Engine\Binaries\ThirdParty\Python3\Win64\python.exe" |
| 27 | + echo [detect-ue-path] Found UE %%V Python via registry |
| 28 | + ) |
| 29 | + ) |
| 30 | + ) |
| 31 | +) |
| 32 | + |
| 33 | +REM === Method 2: Check Registry for Custom/Source builds === |
| 34 | +if "!PYTHON_EXE!"=="" ( |
| 35 | + for /f "tokens=1,2*" %%A in ('reg query "HKEY_CURRENT_USER\SOFTWARE\Epic Games\Unreal Engine\Builds" 2^>nul') do ( |
| 36 | + if "!PYTHON_EXE!"=="" ( |
| 37 | + if "%%B"=="REG_SZ" ( |
| 38 | + set "UE_DIR=%%C" |
| 39 | + if exist "!UE_DIR!\Engine\Binaries\ThirdParty\Python3\Win64\python.exe" ( |
| 40 | + set "PYTHON_EXE=!UE_DIR!\Engine\Binaries\ThirdParty\Python3\Win64\python.exe" |
| 41 | + echo [detect-ue-path] Found custom UE build Python via registry |
| 42 | + ) |
| 43 | + ) |
| 44 | + ) |
| 45 | + ) |
| 46 | +) |
| 47 | + |
| 48 | +REM === Method 3: Check LauncherInstalled.dat === |
| 49 | +if "!PYTHON_EXE!"=="" ( |
| 50 | + set "LAUNCHER_FILE=%PROGRAMDATA%\Epic\UnrealEngineLauncher\LauncherInstalled.dat" |
| 51 | + if exist "!LAUNCHER_FILE!" ( |
| 52 | + for /f "tokens=2 delims=:," %%A in ('type "!LAUNCHER_FILE!" ^| findstr /C:"InstallLocation"') do ( |
| 53 | + if "!PYTHON_EXE!"=="" ( |
| 54 | + set "INSTALL_PATH=%%~A" |
| 55 | + set "INSTALL_PATH=!INSTALL_PATH:"=!" |
| 56 | + set "INSTALL_PATH=!INSTALL_PATH: =!" |
| 57 | + if exist "!INSTALL_PATH!\Engine\Binaries\ThirdParty\Python3\Win64\python.exe" ( |
| 58 | + set "PYTHON_EXE=!INSTALL_PATH!\Engine\Binaries\ThirdParty\Python3\Win64\python.exe" |
| 59 | + echo [detect-ue-path] Found UE Python via LauncherInstalled.dat |
| 60 | + ) |
| 61 | + ) |
| 62 | + ) |
| 63 | + ) |
| 64 | +) |
| 65 | + |
| 66 | +REM === Method 4: Common installation paths === |
| 67 | +if "!PYTHON_EXE!"=="" ( |
| 68 | + set "UE_PATHS=C:\Program Files\Epic Games;D:\Program Files\Epic Games;E:\Program Files\Epic Games" |
| 69 | + set "UE_PATHS=!UE_PATHS!;C:\Epic Games;D:\Epic Games;E:\Epic Games" |
| 70 | + set "UE_PATHS=!UE_PATHS!;C:\UE;D:\UE;E:\UE;F:\UE;G:\UE" |
| 71 | + |
| 72 | + set "UE_VERSIONS=UE_5.7 UE_5.6 UE_5.5 UE_5.4 UE_5.3 UE_5.2 UE_5.1 UE_5.0" |
| 73 | + |
| 74 | + for %%P in (!UE_PATHS!) do ( |
| 75 | + for %%V in (!UE_VERSIONS!) do ( |
| 76 | + if "!PYTHON_EXE!"=="" ( |
| 77 | + set "TEST_PATH=%%P\%%V\Engine\Binaries\ThirdParty\Python3\Win64\python.exe" |
| 78 | + if exist "!TEST_PATH!" ( |
| 79 | + set "PYTHON_EXE=!TEST_PATH!" |
| 80 | + echo [detect-ue-path] Found UE Python at common path |
| 81 | + ) |
| 82 | + ) |
| 83 | + ) |
| 84 | + ) |
| 85 | +) |
| 86 | + |
| 87 | +REM === Method 5: System Python === |
| 88 | +if "!PYTHON_EXE!"=="" ( |
| 89 | + where python >nul 2>&1 |
| 90 | + if !ERRORLEVEL! EQU 0 ( |
| 91 | + set "PYTHON_EXE=python" |
| 92 | + echo [detect-ue-path] Using system Python |
| 93 | + ) |
| 94 | +) |
| 95 | + |
| 96 | +if "!PYTHON_EXE!"=="" ( |
| 97 | + where python3 >nul 2>&1 |
| 98 | + if !ERRORLEVEL! EQU 0 ( |
| 99 | + set "PYTHON_EXE=python3" |
| 100 | + echo [detect-ue-path] Using system Python3 |
| 101 | + ) |
| 102 | +) |
| 103 | + |
| 104 | +REM === No Python found === |
| 105 | +if "!PYTHON_EXE!"=="" ( |
| 106 | + echo [detect-ue-path] ERROR: Python not found. |
| 107 | + echo [detect-ue-path] Please install Unreal Engine or Python. |
| 108 | + exit /b 1 |
| 109 | +) |
| 110 | + |
| 111 | +REM Run the Python script to update AGENTS.md |
| 112 | +echo [detect-ue-path] Running UE path detection... |
| 113 | +"!PYTHON_EXE!" "%PYTHON_SCRIPT%" %* |
0 commit comments