From e262a8b004d44acafe3572ae3f0b0773d9ffd909 Mon Sep 17 00:00:00 2001 From: "alexei.dolgolyov" Date: Wed, 8 Apr 2026 00:02:56 +0300 Subject: [PATCH] fix(launcher): set PYTHONPATH and WLED_CONFIG_PATH in start-hidden.vbs MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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. --- server/scripts/start-hidden.vbs | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/server/scripts/start-hidden.vbs b/server/scripts/start-hidden.vbs index 701b8af..6448bea 100644 --- a/server/scripts/start-hidden.vbs +++ b/server/scripts/start-hidden.vbs @@ -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