windows-background-process-launching
Launch durable hidden Windows processes safely.
- License 许可
- MIT
- 最近更新
- 2026-10-20
- Stars
- ★ 0
- Forks
- 0
01 前言 Front Matter
- name
- windows-background-process-launching
- author
- Hermes Agent
- license
- MIT
- version
- 1.0.0
- metadata
- { "hermes": { "tags": [ "windows", "background", "subprocess", "vbs", "services", "process-lifecycle" ], "related_skills": [ "cross-platform-cli-launching", "systematic-debugging" ] } }
- platforms
- [ "windows" ]
- description
- Launch durable hidden Windows processes safely.
02 资源文件 1
- 参考文档references/hermes-dashboard-vbs.md3.4 KB
03 SKILL.md 正文
Windows Background Process Launching Skill
Use this skill when a Windows CLI, daemon, dashboard, gateway, or local service must run asynchronously without opening or flashing a console window. It covers launcher design, environment-derived executable resolution, safe process ownership checks, and runtime verification; it does not replace a real service manager when restart-at-boot or recovery policy is required.
When to Use
- A user asks for a hidden or windowless Windows background launcher.
- A Scheduled Task or Startup-folder entry must start a console CLI silently.
- A launcher must follow a profile-local or relocatable installation root.
- A foreground command works, but double-click/startup execution flashes a console.
- A background smoke test must distinguish the newly launched process from an existing listener.
Do not use this skill for POSIX systemd, launchd, nohup, or tmux workflows.
Prerequisites
- Confirm the requested executable and arguments in a foreground terminal first.
- Identify the authoritative installation-root environment variable, such as
HERMES_HOME. - Confirm whether the process is one-shot or long-lived.
- Decide whether the launcher needs only hidden execution or also boot persistence and restart policy.
- Check whether the target port or singleton resource is already owned before launching.
How to Run
For a hidden user-launched process, prefer a .vbs launcher executed by wscript.exe:
wscript.exe C:\path\to\launcher.vbs
Use Windows Task Scheduler for boot/logon persistence. Point the task at wscript.exe and pass the launcher path as its argument rather than scheduling a .cmd file directly.
See references/hermes-dashboard-vbs.md for a complete environment-derived Hermes Dashboard example and its verification recipe.
Quick Reference
| Requirement | Preferred mechanism |
|---|---|
| No visible console | WScript.Shell.Run command, 0, False |
| Dynamic install root | Read process, user, then system environment at launch time |
| Safe path construction | Scripting.FileSystemObject.BuildPath |
| Spaces in executable path | Quote the executable token explicitly |
| Detached/asynchronous start | bWaitOnReturn=False |
| Missing prerequisite | Exit before launch with a concise actionable error |
| Startup persistence | Task Scheduler invoking wscript.exe |
| Runtime proof | Listener + command line + health endpoint + visible-window check |
Procedure
1. Reproduce the foreground command
Run the exact executable and argv in a visible terminal. Confirm it reaches a stable ready state. Do not debug hidden execution and application startup simultaneously.
2. Resolve paths from the runtime environment
Read the installation root each time the launcher runs. Do not bake one user's absolute home directory into the launcher.
Use this precedence when the script may be launched by a shell, Explorer, or Task Scheduler:
- process environment;
- user environment;
- system environment.
Fail explicitly if the variable is absent. Build the executable path from that root and verify the file exists before launch.
3. Use a GUI-subsystem launcher
Prefer wscript.exe plus VBScript for a truly hidden entry point. A .cmd or console PowerShell entry point can allocate or briefly flash a console before it hides its child.
Launch the console executable itself with window style 0. Do not switch automatically to pythonw.exe: a console-less parent can cause console-subsystem descendants to allocate their own visible windows. A hidden console owned by the long-lived process is usually the more stable process tree.
4. Preserve argument boundaries
Construct the command so the executable path is quoted as one token. Keep static arguments literal and validate any user-controlled arguments before interpolation. Avoid broad shell evaluation merely to get redirection or path lookup.
5. Separate hidden launch from persistence
A hidden asynchronous launch is not a service contract. If the process must survive reboot, configure Task Scheduler with:
- a deterministic trigger;
- the intended user identity;
wscript.exeas the program;- the absolute
.vbspath as the argument; - an explicit working directory when the application depends on it;
- restart-on-failure behavior appropriate to the application.
6. Verify the real process
Use several independent facts rather than one status command:
- identify every listener or process matching the requested resource;
- inspect the owning process command line;
- confirm the command line contains the dynamically resolved executable and intended argv;
- call one health/status endpoint or equivalent protocol check;
- enumerate visible top-level windows for the owning PID and require none.
When a port is already occupied, do not kill the first returned PID. Windows may have listeners associated with different local addresses or pre-existing companion services. Confirm executable path and argv before terminating anything.
Pitfalls
- Hard-coding
C:\Users\name\...instead of resolving the profile/install root. - Assuming a variable present in the current shell is persisted into Explorer or Task Scheduler; check process/user/system scopes deliberately.
- Treating
--no-openas hidden execution; it only prevents browser launch, not console creation. - Using
.cmdas the outermost scheduled entry point when zero console flash is required. - Replacing a console interpreter with
pythonw.exewithout testing descendant console behavior. - Declaring success because a process exists while its port or health endpoint is not ready.
- Declaring failure from one process-status helper while the requested protocol endpoint is healthy.
- Killing a port owner without matching its executable and arguments to the process created by the test.
- Re-running a launcher against an occupied singleton port and interpreting the hidden child’s quick exit as a launcher bug.
- Leaving application-startup errors entirely invisible; use preflight checks, application logs, or a health probe.
Verification
A complete verification records:
- the launcher file exists at the requested location;
- the environment variable resolves to the expected root at runtime;
- the derived executable exists;
wscript.exeaccepts the script without a VBScript error;- the long-lived process command line contains the expected executable and arguments;
- one application-level health check succeeds;
- the owner PID has no visible top-level windows;
- any pre-existing process or listener was preserved unless the user explicitly authorized replacement.
For test cleanup, terminate only the PID whose executable and argv match the launched fixture. If ownership cannot be proven, stop and report the conflict rather than widening the kill scope.
04 同仓库更多 Skills
web-retrieval-resilience
Web tools fail or search rules break: repair or fall back.
blocked-page-recovery
Use when a fetch fails: 403/429, paywall, WAF, bot wall.
verification-loop
Run a six-phase verification of a Claude Code session's work — build, type check, lint, tests with coverage, security grep, and diff review — then produce a PASS/FAIL verification report. Use when verifying work after completing a feature or refactor, before creating a PR, or when quality gates must pass.
unreal-world-builder
开放世界与环境专家——精通 UE5 World Partition、Landscape、程序化植被、HLOD 和大规模关卡流式加载,打造无缝开放世界体验
unreal-technical-artist
Unreal Engine 视觉管线专家——精通材质编辑器、Niagara 特效、程序化内容生成和 UE5 项目的美术到引擎管线
unreal-systems-engineer
性能与混合架构专家——精通 C++/Blueprint 边界、Nanite 几何体、Lumen GI 和 Gameplay Ability System,面向 AAA 级 Unreal Engine 项目