Skip to content

fix(windows): hide startup fallback launcher with VBS#91249

Closed
deepujain wants to merge 3 commits into
openclaw:mainfrom
deepujain:fix/70788-startup-vbs-silent-launch
Closed

fix(windows): hide startup fallback launcher with VBS#91249
deepujain wants to merge 3 commits into
openclaw:mainfrom
deepujain:fix/70788-startup-vbs-silent-launch

Conversation

@deepujain

Copy link
Copy Markdown
Contributor

Summary

What problem does this PR solve?

  • Windows Startup-folder fallback installs currently launch the gateway through a visible cmd.exe hop.
  • Even with start /min, Windows still flashes the terminal frame briefly at logon before minimizing it.
  • This PR switches the Startup-folder fallback to a hidden .vbs launcher by default so the gateway starts without the visible console flash.

Why does this matter now?

What is the intended outcome?

  • When Task Scheduler is unavailable and OpenClaw falls back to the Startup folder, the installed login item launches silently with no visible cmd.exe frame.

What is intentionally out of scope?

  • No change to the main Task Scheduler install/update path.
  • No change to the gateway command script itself (gateway.cmd).
  • No change to runtime/service detection beyond continuing to recognize and clean up both .vbs and legacy .cmd Startup entries.

What does success look like?

  • Startup fallback writes a hidden .vbs launcher by default.
  • Existing stop/restart/uninstall flows still work with the new default and with legacy .cmd fallback entries.

What should reviewers focus on?

  • resolveStartupEntryPath() now defaults the Startup-folder fallback to .vbs.
  • activateScheduledTask() now always writes the hidden launcher for the Startup fallback path.
  • The focused fallback tests still cover install, stop/restart, and legacy cleanup behavior.

Linked context

Which issue does this close?

Closes #70788

Which issues, PRs, or discussions are related?

Related #57682 for the same visible-console root cause on a different Windows launch path.

Was this requested by a maintainer or owner?

No maintainer request found; the issue is labeled clawsweeper:queueable-fix, clawsweeper:fix-shape-clear, and clawsweeper:source-repro.

Real behavior proof (required for external PRs)

  • Behavior or issue addressed: Windows Startup-folder fallback no longer generates a visible cmd.exe launch hop by default.

  • Real environment tested: local source checkout on macOS/Linux using the production Windows fallback installer path under mocked schtasks denial and Windows env in the daemon Vitest suites.

  • Exact steps or command run after this patch:

    • node scripts/run-vitest.mjs src/daemon/schtasks.startup-fallback.test.ts src/daemon/schtasks.install.test.ts src/daemon/schtasks.test.ts src/daemon/schtasks.stop.test.ts
  • Evidence after fix:

    Startup fallback install now writes the Startup entry as .vbs by default.
    The generated launcher contains:
    CreateObject("WScript.Shell").Run """<gateway.cmd>""", 0, False
    
  • Observed result after fix: the fallback install tests now assert that the installed Startup entry is the hidden VBS launcher by default, while stop/restart/runtime tests continue to pass against the same fallback lifecycle.

  • What was not tested: a live native Windows login session proving compositor-level no visible flash behavior. This environment does not provide an interactive Windows desktop.

  • Proof limitations or environment constraints: the proof is limited to the production fallback-generation path and lifecycle tests, not a live Windows desktop login.

Tests and validation

Which commands did you run?

node scripts/run-vitest.mjs src/daemon/schtasks.startup-fallback.test.ts src/daemon/schtasks.install.test.ts src/daemon/schtasks.test.ts src/daemon/schtasks.stop.test.ts
git diff --check

What regression coverage was added or updated?

  • Updated Startup fallback tests to assert the default installed login item is now .vbs.
  • Existing lifecycle tests continue to cover fallback install, restart, stop, and uninstall/cleanup.

What failed before this fix, if known?

  • The Startup-folder fallback used start "" /min cmd.exe /d /c ..., which still flashes a visible console frame before minimizing.

If no test was added, why not?

  • Existing focused tests were updated for the new default behavior instead of adding a separate redundant case.

Risk checklist

Did user-visible behavior change? (Yes/No)

Yes.

Did config, environment, or migration behavior change? (Yes/No)

No.

Did security, auth, secrets, network, or tool execution behavior change? (Yes/No)

No.

What is the highest-risk area?

  • Windows fallback lifecycle compatibility for installs that already have legacy .cmd Startup entries.

How is that risk mitigated?

  • Uninstall and install-state checks already consider both .vbs and legacy .cmd paths, and the focused fallback lifecycle tests remain green after the default switch.

Current review state

What is the next action?

  • ClawSweeper review and maintainer review.

What is still waiting on author, maintainer, CI, or external proof?

  • CI and maintainer review.
  • Live native Windows desktop proof is still unavailable in this environment.

Which bot or reviewer comments were addressed?

@openclaw-barnacle openclaw-barnacle Bot added gateway Gateway runtime triage: mock-only-proof Candidate: PR proof only shows tests, mocks, snapshots, lint, typecheck, or CI. size: XS labels Jun 7, 2026

Copy link
Copy Markdown
Contributor Author

Focused Windows fallback change is up on the branch now. Local validation used node scripts/run-vitest.mjs src/daemon/schtasks.startup-fallback.test.ts src/daemon/schtasks.install.test.ts src/daemon/schtasks.test.ts src/daemon/schtasks.stop.test.ts plus git diff --check.

Scope is intentionally narrow: Startup-folder fallback now writes the hidden .vbs launcher by default, while cleanup/install-state still recognize legacy .cmd entries too.

@clawsweeper

clawsweeper Bot commented Jun 7, 2026

Copy link
Copy Markdown
Contributor

Thanks for the context here. I did a careful shell check against current main, and this is already implemented.

Close: current main already routes generated Windows gateway installs through the hidden launcher path, including the activation env used by the Startup-folder fallback, so this branch is now a conflicting duplicate with only secondary docs/test residue.

Root-cause cluster
Relationship: superseded
Canonical: #95480
Summary: The merged Windows gateway hidden-launcher PR now supersedes this narrower Startup-folder fallback branch for the observable user problem.

Members:

Proposal only: this assessment does not dispatch repair, suppress jobs, mutate sibling items, close, or merge anything.

So I’m closing this as already implemented rather than keeping a duplicate issue open.

Review details

Best possible solution:

Keep current main's generated service-env hidden-launcher implementation and handle any remaining docs/gateway wording as a narrow follow-up if maintainers want it.

Do we have a high-confidence way to reproduce the issue?

No current-main failure path remains for the production gateway install route: source inspection shows generated gateway installs now carry the hidden-launcher marker into activation and fallback handling. The original base behavior was source-reproducible from the .cmd fallback path, but current main no longer matches that path for generated installs.

Is this the best way to solve the issue?

Yes. Current main is the better solution now because it applies the hidden launcher at the generated service-env boundary and preserves caller-owned identity, rather than landing this older conflicted branch's lower-level unconditional fallback change.

Security review:

Security review cleared: No security or supply-chain concern was found in the PR diff; the WScript launcher default is tracked as compatibility and availability risk.

AGENTS.md: found and applied where relevant.

What I checked:

  • Current main sets the generated gateway hidden-launcher default: buildServiceEnvironment() now sets OPENCLAW_WINDOWS_TASK_HIDDEN_LAUNCHER: "1" for generated gateway service installs, which is the source-of-truth environment used by the normal install path. (src/daemon/service-env.ts:438, 448b7c75b669)
  • Current main carries generated defaults into activation and fallback handling: resolveScheduledTaskActivationEnv() copies the hidden-launcher marker from generated service env, and installScheduledTask() passes that activation env into activateScheduledTask(). (src/daemon/schtasks.ts:974, 448b7c75b669)
  • Current main writes the hidden Startup-folder launcher when the marker is present: The fallback path resolves .vbs when the hidden-launcher marker is truthy and writes buildHiddenLauncherScript() output using WScript.Shell.Run(..., 0, False). (src/daemon/schtasks.ts:1271, 448b7c75b669)
  • Current regression coverage protects the generated-env boundary: The install test covers caller env without the hidden marker, generated gateway env with the marker, preserved custom task identity, and Task Scheduler XML targeting gateway.vbs. (src/daemon/schtasks.install.test.ts:251, 448b7c75b669)
  • Git-history provenance for current implementation: Current-main blame ties the generated hidden-launcher env, activation merge, and install/fallback path to commit 31a0f97dd944e0f4af193d400a652ab75612973b, which best proves this checkout's current implementation. (src/daemon/schtasks.ts:974, 31a0f97dd944)
  • Merged related PR provenance: GitHub reports fix #89231: [Bug]: Windows installer-created scheduled task launches gateway.cmd with visible console — should use windowless launcher #95480 merged with commit f5148aff2505020cb01bfffc313aa7cfd768fd59, adding the generated gateway hidden-launcher default and production-shaped scheduler env fix that supersedes this branch. (f5148aff2505)

Likely related people:

  • mikasa0818: Authored the merged PR that added the generated gateway hidden-launcher default and production-shaped scheduler env fix now present on current main. (role: current implementation author; confidence: high; commits: f5148aff2505; files: src/daemon/schtasks.ts, src/daemon/service-env.ts, src/daemon/schtasks.install.test.ts)
  • vincentkoc: Reviewed/co-authored the merged hidden-launcher implementation and has recent adjacent Windows scheduled-task work in the same daemon surface. (role: reviewer and recent area contributor; confidence: high; commits: f5148aff2505, 2a140e6e6ae8; files: src/daemon/schtasks.ts, src/daemon/service-env.ts, src/daemon/schtasks.install.test.ts)
  • steipete: The Windows Startup-folder fallback path and follow-up stop behavior date to commits by Peter Steinberger in the same daemon files. (role: introduced fallback behavior; confidence: high; commits: 433e65711f78, 5189ba851c2d; files: src/daemon/schtasks.ts, src/daemon/schtasks.startup-fallback.test.ts)
  • giodl73-repo: Authored the merged node-service hidden Windows launcher precedent that the current gateway implementation reuses. (role: sibling hidden-launcher contributor; confidence: medium; commits: 9ac7773b7f07; files: src/daemon/node-service.ts, src/daemon/schtasks.ts, src/daemon/service-env.ts)

Codex review notes: model internal, reasoning high; reviewed against 448b7c75b669; fix evidence: commit 31a0f97dd944, main fix timestamp 2026-06-25T08:25:09-07:00.

@clawsweeper clawsweeper Bot added rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask. P2 Normal backlog priority with limited blast radius. merge-risk: 🚨 compatibility 🚨 May break existing users, config, migrations, defaults, or upgrade paths. labels Jun 7, 2026
@openclaw-barnacle openclaw-barnacle Bot added docs Improvements or additions to documentation size: S and removed size: XS labels Jun 8, 2026

Copy link
Copy Markdown
Contributor Author

Follow-up pushed on the existing branch. I restored explicit legacy .cmd startup-fallback coverage in the Windows tests, kept the hidden-launcher path explicit for .vbs, and updated the gateway/uninstall docs to describe the current .vbs default plus legacy .cmd cleanup. Validation: git diff --check. I also attempted the focused startup-fallback vitest, but this worktree is missing an internal package dependency (@openclaw/fs-safe/config) needed to execute that suite locally. Commit: 1d9211b8eb.

@clawsweeper clawsweeper Bot added rating: 🧂 unranked krab Not merge-ready due to missing proof or serious correctness/safety concerns. and removed rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. labels Jun 8, 2026
@deepujain

Copy link
Copy Markdown
Contributor Author

Pushed a focused test fix for the command-support CI failure. The Startup fallback test helper now defaults to the new .vbs path, matching the production default while legacy .cmd coverage stays explicit. Validation: node scripts/run-vitest.mjs src/daemon/schtasks.startup-fallback.test.ts and git diff --check pass locally; the local commit hook was skipped because this machine has Node 22.12.0 while the branch Corepack path requires pnpm 11.2.2 on Node >=22.13.

@clawsweeper

clawsweeper Bot commented Jun 26, 2026

Copy link
Copy Markdown
Contributor

ClawSweeper applied the proposed close for this PR.

@clawsweeper clawsweeper Bot closed this Jun 26, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

docs Improvements or additions to documentation gateway Gateway runtime merge-risk: 🚨 availability 🚨 May cause crashes, hangs, restart loops, stalls, or process outages. merge-risk: 🚨 compatibility 🚨 May break existing users, config, migrations, defaults, or upgrade paths. P2 Normal backlog priority with limited blast radius. rating: 🧂 unranked krab Not merge-ready due to missing proof or serious correctness/safety concerns. size: S status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask. triage: mock-only-proof Candidate: PR proof only shows tests, mocks, snapshots, lint, typecheck, or CI.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

fix(windows): suppress startup-folder cmd window flash via wscript silent launcher

1 participant