summaryrefslogtreecommitdiff
path: root/ControllerFirmware/flash-controller.bat
blob: f08023a23d74e366db30ee47ae6898692d2a601f (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
@echo off
rem ===================================================================
rem  NRL - Flash the Controller  (double-click launcher, Windows)
rem  Writes the prebuilt controller firmware to a plugged-in controller.
rem ===================================================================
setlocal
title NRL - Flash Controller

set "SCRIPT=%~dp0flash_controller.py"

rem Find a usable Python 3 via the kit's installer helper (in ..\tools\);
rem if this ControllerFirmware folder was copied without tools\, fall back
rem to whatever py/python is already on this PC.
set "ENSURE=%~dp0..\tools\ensure-python.ps1"
set "PYEXE="
if exist "%ENSURE%" (
    for /f "usebackq delims=" %%i in (`powershell -NoProfile -ExecutionPolicy Bypass -File "%ENSURE%"`) do set "PYEXE=%%i"
)
if defined PYEXE goto run

where py >nul 2>nul
if errorlevel 1 goto try_python
set "PYEXE=py"
goto run

:try_python
where python >nul 2>nul
if errorlevel 1 goto no_python
set "PYEXE=python"
goto run

:run
"%PYEXE%" "%SCRIPT%" %*
goto end

:no_python
echo.
echo [error] Python 3 was not found and could not be installed automatically.
echo   Install Python 3 from https://www.python.org/downloads/ and re-run,
echo   ticking "Add python.exe to PATH" during setup.

:end
echo.
if not defined NRL_NO_PAUSE pause
endlocal