Client or integration
Codex CLI
Area
Service lifecycle
Summary
On Windows, ocx service install stops the proxy and removes opencodex's injected Codex config keys before it discovers it needs elevation. When the schtasks call is then denied, the teardown is not undone — so a failed install leaves a previously working setup broken.
Observed sequence:
ocx service install stops the running proxy and restores native Codex routing (removing openai_base_url and model_catalog_json from <CODEX_HOME>/config.toml).
- It then runs
schtasks /create ..., which fails because the shell is not elevated:
❌ Service install cleanup failed: Windows access denied while running Task Scheduler.
Command: schtasks /create /tn opencodex-proxy /xml <OPENCODEX_HOME>\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
- The service is not installed and the proxy is left stopped with routing removed.
ocx status afterwards reports Restart safety: native Codex routing (no opencodex restart dependency).
Expected: elevation is checked (or the task creation attempted) before any teardown, so that a permission failure is a no-op; or the teardown is rolled back when install fails.
The message text does anticipate the failure ("Approve the Windows UAC prompt… or run from an elevated PowerShell window"), so the elevation requirement is known in advance — it just is not checked early enough.
Reproduction
100% reproducible on my machine.
- Have a working opencodex install with the proxy running and Codex routed through it.
- From a non-elevated shell, run
ocx service install.
- Observe the access-denied error above.
- Check
<CODEX_HOME>/config.toml — openai_base_url and model_catalog_json are gone.
- Check the proxy — stopped.
Recovering is harder than it should be because ocx restore back and ocx sync both refuse afterwards with a message naming no reason (filed separately). I restored routing by hand using the keys in <CODEX_HOME>/opencodex.config.toml.
Suggested fixes
- Probe for elevation (or attempt the
schtasks create) before stopping the proxy and un-injecting the config. A permissions failure should leave the system exactly as it was found.
- Failing that, make the cleanup path actually restore what the install path removed — the current message says "Service install cleanup failed", so a cleanup step exists but does not cover the config/proxy teardown.
- Consider detecting non-elevated invocation up front and printing the "run from an elevated PowerShell window" guidance instead of starting the install at all.
Version
2.11.0 (the install path is unchanged in 2.12.0 as far as I can tell from the release notes)
Operating system
Windows 11 Pro 10.0.26200
Provider and model
Not provider-specific.
Logs or error output
$ ocx health --json
{"ok":true,"pid":19940,"port":10100}
$ ocx service install
❌ Service install cleanup failed: Windows access denied while running Task Scheduler.
Command: schtasks /create /tn opencodex-proxy /xml <OPENCODEX_HOME>\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
$ ocx health --json
{"ok":false,"pid":null,"port":null}
$ ocx service status
❌ service not installed (Task Scheduler).
$ ocx status
❌ Proxy: not running
Restart safety: native Codex routing (no opencodex restart dependency)
Service: not installed
# and the injected keys are gone from <CODEX_HOME>/config.toml:
# openai_base_url -> removed
# model_catalog_json -> removed
Screenshots and supporting files
No response
Redacted configuration
{
"providers": {
"openai": { "adapter": "openai-responses", "codexAccountMode": "direct", "authMode": "forward" }
},
"codexAutoStart": true,
"activeCodexAccountId": "__main__"
}
Windows sandbox mode is unelevated in the Codex config; the shell used was a normal (non-admin) terminal.
Checks
Client or integration
Codex CLI
Area
Service lifecycle
Summary
On Windows,
ocx service installstops the proxy and removes opencodex's injected Codex config keys before it discovers it needs elevation. When theschtaskscall is then denied, the teardown is not undone — so a failed install leaves a previously working setup broken.Observed sequence:
ocx service installstops the running proxy and restores native Codex routing (removingopenai_base_urlandmodel_catalog_jsonfrom<CODEX_HOME>/config.toml).schtasks /create ..., which fails because the shell is not elevated:ocx statusafterwards reportsRestart safety: native Codex routing (no opencodex restart dependency).Expected: elevation is checked (or the task creation attempted) before any teardown, so that a permission failure is a no-op; or the teardown is rolled back when install fails.
The message text does anticipate the failure ("Approve the Windows UAC prompt… or run from an elevated PowerShell window"), so the elevation requirement is known in advance — it just is not checked early enough.
Reproduction
100% reproducible on my machine.
ocx service install.<CODEX_HOME>/config.toml—openai_base_urlandmodel_catalog_jsonare gone.Recovering is harder than it should be because
ocx restore backandocx syncboth refuse afterwards with a message naming no reason (filed separately). I restored routing by hand using the keys in<CODEX_HOME>/opencodex.config.toml.Suggested fixes
schtaskscreate) before stopping the proxy and un-injecting the config. A permissions failure should leave the system exactly as it was found.Version
2.11.0 (the install path is unchanged in 2.12.0 as far as I can tell from the release notes)
Operating system
Windows 11 Pro 10.0.26200
Provider and model
Not provider-specific.
Logs or error output
$ ocx health --json {"ok":true,"pid":19940,"port":10100} $ ocx service install ❌ Service install cleanup failed: Windows access denied while running Task Scheduler. Command: schtasks /create /tn opencodex-proxy /xml <OPENCODEX_HOME>\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 $ ocx health --json {"ok":false,"pid":null,"port":null} $ ocx service status ❌ service not installed (Task Scheduler). $ ocx status ❌ Proxy: not running Restart safety: native Codex routing (no opencodex restart dependency) Service: not installed # and the injected keys are gone from <CODEX_HOME>/config.toml: # openai_base_url -> removed # model_catalog_json -> removedScreenshots and supporting files
No response
Redacted configuration
{ "providers": { "openai": { "adapter": "openai-responses", "codexAccountMode": "direct", "authMode": "forward" } }, "codexAutoStart": true, "activeCodexAccountId": "__main__" }Windows sandbox mode is
unelevatedin the Codex config; the shell used was a normal (non-admin) terminal.Checks