Client or integration
CLI — ocx service install on Windows from a non-elevated PowerShell 7 terminal.
Area
Service install / Task Scheduler registration — src/lib/windows-elevation.ts → runWindowsElevatedScheduledTaskRegistration() (the fresh-install elevated fallback used by registerFreshWindowsSchedulerTask() in service.ts).
Summary
On a clean install with no existing opencodex-proxy scheduled task, ocx service install fails immediately with ❌ Service install cleanup failed: Background service install failed with exit code 199. and never shows the UAC prompt. Expected: the elevated fallback should prompt UAC, run Register-ScheduledTask, then publish assets and serve on port 10100.
The failure is a launcher-script bug, not a UAC-denial edge case. runWindowsElevatedScheduledTaskRegistration() builds the elevated PowerShell launcher by joining its array with "; ", which terminates the Start-Process statement right after -FilePath. The resulting script is:
$p = Start-Process -FilePath 'C:\WINDOWS\system32\WindowsPowerShell\v1.0\powershell.exe'; -ArgumentList '-NoProfile ...'; -Verb RunAs -WindowStyle Hidden -PassThru -Wait; if ($null -eq $p) { exit 1223 } ...
So -ArgumentList and -Verb RunAs become standalone statements → two CommandNotFoundException errors, elevation never runs (no UAC), and PowerShell exits with a spurious code (observed 199) that the CLI surfaces verbatim. The adjacent runWindowsElevated() builds the same kind of launcher correctly using join("") with ; terminators embedded on the previous lines.
Reproduction
- Fresh
npm i -g @bitkyc08/opencodex (2.19.0), or ensure no task exists: schtasks /delete /tn opencodex-proxy /f
- From a non-elevated PowerShell 7:
ocx service install
- Observe: no UAC prompt appears; it prints
❌ Service install cleanup failed: Background service install failed with exit code 199.
I also verified that elevation itself works on this machine: a manual elevated Register-ScheduledTask with the same generated task XML succeeds (exit 0). The malformed launcher script is the only failing piece.
Version
@bitkyc08/opencodex 2.19.0 (latest on npm)
Operating system
Windows 11 24H2 (build 10.0.26200), non-elevated PowerShell 7.5
Provider and model
N/A — not provider-specific
Logs or error output
CLI:
❌ Service install cleanup failed: Background service install failed with exit code 199.
Elevated launcher stderr (captured by instrumenting startPowerShellCommand):
-ArgumentList : The term '-ArgumentList' is not recognized as the name of a cmdlet, function, script file, or operable
program. Check the spelling of the name, or if a path was included, verify that the path is correct and try again.
At line:1 char:92
+ ... stem32\WindowsPowerShell\v1.0\powershell.exe'; -ArgumentList '-NoPro ...
+ ~~~~~~~~~~~~~
+ CategoryInfo : ObjectNotFound: (-ArgumentList:String) [], CommandNotFoundException
+ FullyQualifiedErrorId : CommandNotFoundException
-Verb : The term '-Verb' is not recognized as the name of a cmdlet, function, script file, or operable program. Check
the spelling of the name, or if a path was included, verify that the path is correct and try again.
At line:1 char:11070
+ ... aQBvAG4AIABTAHQAbwBwACAAfAAgAE8AdQB0AC0ATgB1AGwAbAA='; -Verb RunAs - ...
+ ~~~~~
+ CategoryInfo : ObjectNotFound: (-Verb:String) [], CommandNotFoundException
+ FullyQualifiedErrorId : CommandNotFoundException
Screenshots and supporting files
n/a
Redacted configuration
None required — no configuration shape is involved.
Suggested fix
In runWindowsElevatedScheduledTaskRegistration(), mirror runWindowsElevated(): move the ; terminators onto the preceding lines and join(""):
const script = [
`$p = Start-Process -FilePath ${psSingleQuote(windowsPowerShell())}`,
` -ArgumentList ${psSingleQuote(buildWindowsElevatedArgumentList([...]))}`,
" -Verb RunAs -WindowStyle Hidden -PassThru -Wait;",
`if ($null -eq $p) { exit ${OCX_ELEVATED_UAC_CANCELLED} }`,
"$null = $p.Handle;",
`if ($null -eq $p.ExitCode) { exit ${OCX_ELEVATED_PROTOCOL_FAILED} }`,
"exit $p.ExitCode",
].join("");
With this one-line fix the identical reproduction completes successfully: task \opencodex-proxy registered (ownership nonce), assets published under ~/.opencodex, and the proxy serving on port 10100.
Checks
Client or integration
CLI —
ocx service installon Windows from a non-elevated PowerShell 7 terminal.Area
Service install / Task Scheduler registration —
src/lib/windows-elevation.ts→runWindowsElevatedScheduledTaskRegistration()(the fresh-install elevated fallback used byregisterFreshWindowsSchedulerTask()inservice.ts).Summary
On a clean install with no existing
opencodex-proxyscheduled task,ocx service installfails immediately with❌ Service install cleanup failed: Background service install failed with exit code 199.and never shows the UAC prompt. Expected: the elevated fallback should prompt UAC, runRegister-ScheduledTask, then publish assets and serve on port 10100.The failure is a launcher-script bug, not a UAC-denial edge case.
runWindowsElevatedScheduledTaskRegistration()builds the elevated PowerShell launcher by joining its array with"; ", which terminates theStart-Processstatement right after-FilePath. The resulting script is:So
-ArgumentListand-Verb RunAsbecome standalone statements → twoCommandNotFoundExceptionerrors, elevation never runs (no UAC), and PowerShell exits with a spurious code (observed 199) that the CLI surfaces verbatim. The adjacentrunWindowsElevated()builds the same kind of launcher correctly usingjoin("")with;terminators embedded on the previous lines.Reproduction
npm i -g @bitkyc08/opencodex(2.19.0), or ensure no task exists:schtasks /delete /tn opencodex-proxy /focx service install❌ Service install cleanup failed: Background service install failed with exit code 199.I also verified that elevation itself works on this machine: a manual elevated
Register-ScheduledTaskwith the same generated task XML succeeds (exit 0). The malformed launcher script is the only failing piece.Version
@bitkyc08/opencodex 2.19.0 (latest on npm)
Operating system
Windows 11 24H2 (build 10.0.26200), non-elevated PowerShell 7.5
Provider and model
N/A — not provider-specific
Logs or error output
CLI:
Elevated launcher stderr (captured by instrumenting
startPowerShellCommand):Screenshots and supporting files
n/a
Redacted configuration
None required — no configuration shape is involved.
Suggested fix
In
runWindowsElevatedScheduledTaskRegistration(), mirrorrunWindowsElevated(): move the;terminators onto the preceding lines andjoin(""):With this one-line fix the identical reproduction completes successfully: task
\opencodex-proxyregistered (ownership nonce), assets published under~/.opencodex, and the proxy serving on port 10100.Checks