fix(launcher): set PYTHONPATH and WLED_CONFIG_PATH in start-hidden.vbs
Lint & Test / test (push) Successful in 2m1s
Lint & Test / test (push) Successful in 2m1s
The VBS launcher (used by Start Menu, desktop, and autostart shortcuts
created by the NSIS installer) ran pythonw.exe without setting any env
vars. LedGrab.bat sets PYTHONPATH and WLED_CONFIG_PATH; the VBS did not.
With CWD set to the install root, config.py fell through to its default
lookup (./config/default_config.yaml), which does not exist there — the
real file is at app/config/default_config.yaml. The server silently ran
with built-in defaults on every shortcut launch: no devices, wrong data
dir, nothing persisted where the user expected.
The fix uses WshShell.Environment("Process") to set env vars on the
current VBS process, which child processes spawned via .Run inherit.
Kept CurrentDirectory = appRoot to preserve prior behavior for anyone
depending on CWD-relative paths inside the app.
This commit is contained in:
@@ -1,9 +1,23 @@
|
||||
' Launch wled_controller silently (no console, no window).
|
||||
' Used by the Start Menu / autostart / desktop shortcut created by the
|
||||
' NSIS installer. Must set the same env vars as LedGrab.bat, otherwise
|
||||
' the server runs with built-in defaults (wrong config path, wrong data
|
||||
' dir) and the UI appears to be unconfigured on every startup.
|
||||
|
||||
Set fso = CreateObject("Scripting.FileSystemObject")
|
||||
Set WshShell = CreateObject("WScript.Shell")
|
||||
|
||||
' Get the directory of this script (scripts\), then go up to app root
|
||||
scriptDir = fso.GetParentFolderName(WScript.ScriptFullName)
|
||||
appRoot = fso.GetParentFolderName(scriptDir)
|
||||
WshShell.CurrentDirectory = appRoot
|
||||
|
||||
' Set environment variables for the child process. WshShell.Environment("Process")
|
||||
' is writable and child processes spawned via Run inherit it.
|
||||
Set procEnv = WshShell.Environment("Process")
|
||||
procEnv("PYTHONPATH") = appRoot & "\app\src"
|
||||
procEnv("WLED_CONFIG_PATH") = appRoot & "\app\config\default_config.yaml"
|
||||
|
||||
' Use embedded Python if present (installed dist), otherwise system Python
|
||||
embeddedPython = appRoot & "\python\pythonw.exe"
|
||||
If fso.FileExists(embeddedPython) Then
|
||||
|
||||
Reference in New Issue
Block a user