-
-
Notifications
You must be signed in to change notification settings - Fork 80.7k
fix(windows): suppress startup-folder cmd window flash via wscript silent launcher #70788
Copy link
Copy link
Closed
Closed
Copy link
Labels
P2Normal backlog priority with limited blast radius.Normal backlog priority with limited blast radius.clawsweeper:linked-pr-openClawSweeper found an open linked pull request for this issue.ClawSweeper found an open linked pull request for this issue.clawsweeper:needs-product-decisionClawSweeper marked this issue as needing a product or behavior decision.ClawSweeper marked this issue as needing a product or behavior decision.clawsweeper:no-new-fix-prClawSweeper does not recommend queueing a new automated fix PR for this issue.ClawSweeper does not recommend queueing a new automated fix PR for this issue.clawsweeper:source-reproClawSweeper found a high-confidence source-level issue reproduction.ClawSweeper found a high-confidence source-level issue reproduction.impact:otherThis issue has meaningful maintainer-visible impact outside the owned taxonomy.This issue has meaningful maintainer-visible impact outside the owned taxonomy.issue-rating: 🦞 diamond lobsterVery strong issue quality with high-confidence source-level or clear reproduction.Very strong issue quality with high-confidence source-level or clear reproduction.
Description
Metadata
Metadata
Assignees
Labels
P2Normal backlog priority with limited blast radius.Normal backlog priority with limited blast radius.clawsweeper:linked-pr-openClawSweeper found an open linked pull request for this issue.ClawSweeper found an open linked pull request for this issue.clawsweeper:needs-product-decisionClawSweeper marked this issue as needing a product or behavior decision.ClawSweeper marked this issue as needing a product or behavior decision.clawsweeper:no-new-fix-prClawSweeper does not recommend queueing a new automated fix PR for this issue.ClawSweeper does not recommend queueing a new automated fix PR for this issue.clawsweeper:source-reproClawSweeper found a high-confidence source-level issue reproduction.ClawSweeper found a high-confidence source-level issue reproduction.impact:otherThis issue has meaningful maintainer-visible impact outside the owned taxonomy.This issue has meaningful maintainer-visible impact outside the owned taxonomy.issue-rating: 🦞 diamond lobsterVery strong issue quality with high-confidence source-level or clear reproduction.Very strong issue quality with high-confidence source-level or clear reproduction.
Type
Fields
Priority
None yet
Problem
On Windows, the Startup folder login item (
OpenClaw Gateway.cmd) launches the gateway using:```batch
start "" /min cmd.exe /d /c C:\Users<user>.openclaw\gateway.cmd
```
The `/min` flag minimizes the window but does not suppress rendering — Windows still composites the `cmd.exe` frame before minimizing it. On Windows 11 this produces a visible white/black terminal flash on screen at every login.
Root location: `src/daemon/schtasks.ts` → `renderStartupLaunchCommand()` / `buildStartupLauncherScript()`
This is the startup-folder variant of the same root cause in #57682 (visible CMD window during `openclaw update` gateway restart).
Environment
Expected Behaviour
Gateway starts at login with zero visible window — no flash, no minimized taskbar entry.
Proposed Fix
Replace `start "" /min cmd.exe` with a `wscript.exe` VBScript shim. `wscript.exe` with window style `0` suppresses the window before the process is created — the frame never enters the compositor. This is the canonical Windows method for truly invisible background process launch.
The fix lives entirely in `src/daemon/schtasks.ts`. Instead of one `.cmd` in the Startup folder, generate two files:
`src/daemon/schtasks.ts` — `renderStartupLaunchCommand()`:
```typescript
// BEFORE
function renderStartupLaunchCommand(scriptPath: string): string {
return `start "" /min cmd.exe /d /c ${quoteCmdScriptArg(scriptPath)}`;
}
function buildStartupLauncherScript(opts: StartupScriptOpts): string {
const lines = ['@echo off'];
if (opts.description) lines.push(`rem ${opts.description}`);
lines.push(renderStartupLaunchCommand(opts.scriptPath));
return lines.join('\r\n') + '\r\n';
}
```
```typescript
// AFTER
const VBS_LAUNCHER_FILENAME = 'OpenClaw Gateway.vbs';
// window style 0 = hidden — frame is never created, zero flash
function buildStartupVbsLauncher(gatewayCmdPath: string): string {
const escaped = gatewayCmdPath.replace(/"/g, '""');
return [
`Set sh = CreateObject("WScript.Shell")`,
`sh.Run "cmd.exe /d /c """ & "${escaped}" & """", 0, False`,
].join('\r\n') + '\r\n';
}
function buildStartupLauncherScript(opts: StartupScriptOpts): string {
const vbsPath = path.join(path.dirname(opts.startupItemPath), VBS_LAUNCHER_FILENAME);
const lines = ['@echo off'];
if (opts.description) lines.push(`rem ${opts.description}`);
// delegate to .vbs so service detector still finds the .cmd at its registered path
lines.push(`wscript.exe //nologo "${vbsPath}"`);
return lines.join('\r\n') + '\r\n';
}
export { buildStartupVbsLauncher, VBS_LAUNCHER_FILENAME };
```
Install path (wherever `installStartupFolderItem` writes the `.cmd`): also write the `.vbs` alongside it.
Uninstall path: also remove the `.vbs`.
Why Not Other Approaches
Verified
Related