|
| 1 | +/** Windows Task Scheduler installer, startup fallback, and lifecycle controls. */ |
1 | 2 | import { spawn, spawnSync } from "node:child_process"; |
2 | 3 | import fs from "node:fs/promises"; |
3 | 4 | import os from "node:os"; |
@@ -43,6 +44,8 @@ function resolveTaskName(env: GatewayServiceEnv): string { |
43 | 44 | } |
44 | 45 |
|
45 | 46 | function shouldFallbackToStartupEntry(params: { code: number; detail: string }): boolean { |
| 47 | + // Permission failures and hung schtasks calls can still be served by the |
| 48 | + // per-user Startup folder fallback. |
46 | 49 | return ( |
47 | 50 | params.code === 1 || |
48 | 51 | /(?:access is denied|acceso denegado)/i.test(params.detail) || |
@@ -93,6 +96,8 @@ function resolveStartupEntryPath(env: GatewayServiceEnv, extension?: "cmd" | "vb |
93 | 96 | function resolveStartupEntryPaths(env: GatewayServiceEnv): string[] { |
94 | 97 | const primaryPath = resolveStartupEntryPath(env); |
95 | 98 | const legacyCmdPath = resolveStartupEntryPath(env, "cmd"); |
| 99 | + // Hidden VBS launchers supersede cmd launchers, but uninstall must remove the |
| 100 | + // legacy cmd path from older installs too. |
96 | 101 | return uniqueStrings([primaryPath, legacyCmdPath]); |
97 | 102 | } |
98 | 103 |
|
@@ -257,6 +262,7 @@ export async function readScheduledTaskCommand( |
257 | 262 | if (lower.startsWith("set ")) { |
258 | 263 | const assignment = parseCmdSetAssignment(line.slice(4)); |
259 | 264 | if (assignment) { |
| 265 | + // Generated cmd launchers inline service env before the final command. |
260 | 266 | environment[assignment.key] = assignment.value; |
261 | 267 | } |
262 | 268 | continue; |
|
0 commit comments