Skip to content

Windows: bare ocx service on an already-installed service fails with WINDOWS_SCHTASKS_CREATE_ACCESS_DENIED instead of repairing/restarting #2287

Description

@lidge-jun

Client or integration

Codex CLI

Area

Service lifecycle

Summary

On Windows, running ocx service while the Task Scheduler service is ALREADY installed and running fails with WINDOWS_SCHTASKS_CREATE_ACCESS_DENIED instead of refreshing/restarting the existing service. The bare ocx service path unconditionally goes through install (schtasks /create /f), which requires elevation, so a routine dogfooding restart (update source, then ocx service) dies on UAC even though nothing about the registration needs to change.

Expected behavior: when the service is already installed, ocx service (no subcommand) should take the repair/restart path that ocx service repair provides (no admin re-prompt), or at minimum detect the existing registration and fall back to repair instead of failing with an access-denied error. Additionally there is no ocx service restart subcommand, which is the verb an operator reaches for first; the usage line offers install|repair|start|stop|status|uninstall|remove.

Reproduction

  1. On Windows, install the background service once (elevated): ocx service -> approve UAC. Service runs fine (ocx service status reports Task Scheduler enabled, proxy on port 10100).
  2. Update the source checkout the service points at (dogfooding path: git pull on dev).
  3. From a NON-elevated PowerShell, run ocx service to pick up the new code.
  4. Observe the failure below; the service is not restarted.
  5. ocx service restart is rejected as an unknown subcommand.

ocx service repair is the documented no-admin path, but the bare ocx service invocation (which the CLI describes as "installs/updates and starts the background service") does not route an already-installed service to it.

Version

2.27.0 (local dev checkout, service installed via Task Scheduler)

Operating system

Windows 11

Provider and model

No response

Logs or error output

PS C:\Users\super> ocx service
[X] Service install cleanup failed: Windows access denied while running Task Scheduler. Command: schtasks /create /tn opencodex-proxy /xml C:\Users\super\.opencodex\opencodex-service-task.xml /f Approve the Windows UAC prompt to install the background service, or run `ocx service install` from an elevated PowerShell window.
OCX_ERROR_CODE=WINDOWS_SCHTASKS_CREATE_ACCESS_DENIED

PS C:\Users\super> ocx service restart
Usage: ocx service [install|repair|start|stop|status|uninstall|remove] [--native|--scheduler]
       With no subcommand, installs/updates and starts the background service.
       repair: refresh assets and restart an already-installed service (no admin re-prompt).

Screenshots and supporting files

No response

Redacted configuration

No response

Checks

  • I searched existing issues and documentation.
  • I removed secrets, tokens, account details, request credentials, and personal data.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workingcliCLI, config inject, packaging flagsplatformOS/service/tray/ACL (Windows-heavy, not Windows-only)serviceService lifecycle (WinSW/launchd/scheduler)

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions