fix: use VBS launcher for silent Windows gateway start (no CMD console flash) - #48373
fix: use VBS launcher for silent Windows gateway start (no CMD console flash)#48373Ados6666 wants to merge 1 commit into
Conversation
Task Scheduler always opens a visible CMD console window when executing .cmd files, even when the script immediately launches pythonw.exe (a GUI-subsystem process) and exits. This causes a visible console flash every time the ONLOGON trigger fires. Fix: generate a companion .vbs launcher alongside the existing .cmd. The .vbs runs through wscript.exe (GUI subsystem, no console window) and spawns pythonw.exe with SW_HIDE (0). The .cmd is now a thin wrapper that hands off to the VBS via 'wscript.exe //B //Nologo "%~dp0%~n0.vbs"'. - Add _build_gateway_vbs_script() — generates the VBScript launcher - Simplify _build_gateway_cmd_script() to delegate to the VBS - Update _write_task_script() to write both .cmd and .vbs files - Add/update tests for the new VBS builder and delegation pattern
|
Duplicate of #37037 — same mechanism: generate a companion VBScript launcher run via |
|
Note: This is NOT a duplicate of the prior closed PRs (#37037, #37037, #40696, #38387). The earlier PRs were closed because they were stale (far behind upstream main). This version has been cherry-picked onto the latest origin/main with a clean diff containing only the fix changes. No conflicts. CI green. Ready for review. |
|
Thanks for the focused Windows launcher fix. This is an automated hermes-sweeper review; the requested behavior is already implemented on current
The later implementation therefore satisfies the PR's no-console-flash goal and supersedes this patch. |
Problem
On Windows,
hermes gateway installcreates a Scheduled Task that executes a.cmdbatch file. Task Scheduler invariably opens a visible CMD console window when launching.cmdfiles — even when the script immediately launchespythonw.exe(GUI subsystem, no console) and exits. This causes a visible CMD flash every time the ONLOGON trigger fires.The current
_build_gateway_cmd_script()docstring acknowledges the goal of silent start, noting thatpythonw.exeis a GUI-subsystem executable — but the parent.cmdfile still creates a console window.pythonw.exeprevents the gateway process from showing a window, but does not prevent the CMD host from flashing one.Fix
Generate a companion VBScript launcher (
.vbs) alongside the existing.cmd:.vbsfile — runs viawscript.exe(true GUI subsystem, zero console window), sets environment variables & working directory, then spawnspythonw.exewithSW_HIDE (0).cmdfile — simplified to a thin wrapper:wscript.exe //B //Nologo "%~dp0%~n0.vbs"The scheduled task still points at the
.cmdfile (no change to_install_scheduled_task), preserving the existing schtasks quoting and lifecycle contracts.Changes
hermes_cli/gateway_windows.py:_build_gateway_vbs_script(python_path, working_dir, hermes_home, profile_arg)— generates the VBScript launcher with proper VBS string escaping_build_gateway_cmd_script()— now just hands off to the VBS viawscript.exe, no longer sets env vars or runs pythonw directly_write_task_script()— writes both.cmdand.vbsfiles side by sidetests/hermes_cli/test_gateway_windows.py:test_gateway_cmd_script_delegates_to_vbs_launcher(wastest_gateway_cmd_script_uses_pythonw_without_replace_or_start_churn) — verifies .cmd delegates to VBS, not pythonw directlytest_build_gateway_vbs_script_contains_env_and_hidden_run— verifies VBS sets env vars and callsRun(…, 0, False)test_write_task_script_writes_vbs_with_hermes_home_anchor— verifies VBS is written alongside .cmd with correct working directoryTesting
All 35 tests in
test_gateway_windows.pypass on Windows 10 (Python 3.11):User impact