[CmdletBinding()] param( [string]$CodexHome, [string]$TaskName = 'Codex Force HTTP Provider' ) $ErrorActionPreference = 'Stop' Set-StrictMode -Version 2.0 if (-not $CodexHome) { if ($env:CODEX_HOME) { $CodexHome = $env:CODEX_HOME } elseif ($env:USERPROFILE) { $CodexHome = Join-Path $env:USERPROFILE '.codex' } else { throw 'Cannot determine CODEX_HOME; pass -CodexHome explicitly.' } } $CodexHome = [System.IO.Path]::GetFullPath($CodexHome) $ConfigFile = Join-Path $CodexHome 'config.toml' $Task = Get-ScheduledTask -TaskName $TaskName -ErrorAction SilentlyContinue if ($Task) { Disable-ScheduledTask -TaskName $TaskName | Out-Null Write-Output "Disabled scheduled task: $TaskName" } if (-not (Test-Path -LiteralPath $ConfigFile -PathType Leaf)) { Write-Output "No active config.toml found: $ConfigFile" return } $Timestamp = Get-Date -Format 'yyyyMMdd-HHmmss' $DisabledFile = Join-Path $CodexHome "config.toml.disabled-$Timestamp" Move-Item -LiteralPath $ConfigFile -Destination $DisabledFile Write-Output "Disabled current config without deleting it: $DisabledFile" Write-Output 'Existing config.toml.before-http-*.bak files were not changed.' Write-Output 'Restart ChatGPT and retry Settings. If config.toml reappears, stop and identify the writer before changing it again.'