不废话直接上脚本powershell 管理员启动终端 直接copy执行脚本回车即可原因就是配置文件被三方插件改乱了删除就好了系统会自动生成默认配置的# # ChatGPT Windows 客户端 Windows 安装未完成 一键修复脚本 # 适用场景启动时卡在 Windows 安装未完成 提示 # 根本原因%USERPROFILE%\.codex\config.toml 格式不兼容 # 最后更新2026-07-31 # # 检查是否以管理员身份运行 if (-NOT ([Security.Principal.WindowsPrincipal] [Security.Principal.WindowsIdentity]::GetCurrent()).IsInRole([Security.Principal.WindowsBuiltInRole] Administrator)) { Write-Host -ForegroundColor Red Write-Host 请以管理员身份运行此脚本 -ForegroundColor Red Write-Host 右键 - 使用 PowerShell 以管理员身份运行 -ForegroundColor Yellow Write-Host -ForegroundColor Red Read-Host n按 Enter 退出 exit } Write-Host n -ForegroundColor Cyan Write-Host ChatGPT Windows 客户端一键修复 -ForegroundColor Cyan Write-Host n -ForegroundColor Cyan # 1. 强制关闭所有 ChatGPT/Codex 进程 Write-Host [1/5] 关闭应用进程... -ForegroundColor Yellow $closed taskkill /f /im Codex.exe 2$null taskkill /f /im ChatGPT.exe 2$null Start-Sleep -Seconds 1 Write-Host ✓ 已关闭所有进程 -ForegroundColor Green # 2. 备份并删除损坏的配置文件 Write-Host [2/5] 备份并移除损坏的 config.toml... -ForegroundColor Yellow $configPath $env:USERPROFILE\.codex\config.toml if (Test-Path $configPath) { $timestamp Get-Date -Format yyyyMMdd_HHmmss $backupPath $env:USERPROFILE\.codex\config_$timestamp.toml.bak Move-Item -Path $configPath -Destination $backupPath -Force Write-Host ✓ 已备份到: $backupPath -ForegroundColor Green } else { Write-Host ! 未找到 config.toml跳过 -ForegroundColor Gray } # 3. 清理应用本地缓存 Write-Host [3/5] 清理本地缓存... -ForegroundColor Yellow $cachePaths ( $env:LOCALAPPDATA\Packages\OpenAI.Codex_*\LocalCache, $env:LOCALAPPDATA\Packages\OpenAI.Codex_*\TempState, $env:LOCALAPPDATA\Packages\OpenAI.Codex_*\AC ) $cleaned 0 foreach ($path in $cachePaths) { $resolved Resolve-Path $path -ErrorAction SilentlyContinue if ($resolved) { Remove-Item -Recurse -Force $resolved -ErrorAction SilentlyContinue Write-Host ✓ 已清理: $path -ForegroundColor Green $cleaned } } if ($cleaned -eq 0) { Write-Host ! 未找到缓存目录跳过 -ForegroundColor Gray } # 4. 重置应用 Write-Host [4/5] 重置应用... -ForegroundColor Yellow $appx Get-AppxPackage -Name OpenAI.Codex if ($appx) { $appx | Reset-AppxPackage -ErrorAction SilentlyContinue Write-Host ✓ 应用已重置 -ForegroundColor Green } else { Write-Host ✗ 未找到 OpenAI.Codex请确认已安装 ChatGPT -ForegroundColor Red Read-Host n按 Enter 退出 exit } Start-Sleep -Seconds 2 # 5. 启动应用修复后的正确启动方式 Write-Host [5/5] 启动 ChatGPT... -ForegroundColor Yellow # 获取包信息 $package Get-AppxPackage -Name OpenAI.Codex $packageFamilyName $package.PackageFamilyName $appId $packageFamilyName!App # 方法1通过 Explorer 启动最可靠 try { Start-Process explorer.exe -ArgumentList shell:AppsFolder\$appId Write-Host ✓ 已通过 Explorer 启动 -ForegroundColor Green } catch { # 方法2通过 Shell.Application COM 对象启动 try { $shell New-Object -ComObject Shell.Application $shell.ShellExecute(shell:AppsFolder\$appId, , , open, 1) Write-Host ✓ 已通过 Shell API 启动 -ForegroundColor Green } catch { # 方法3尝试直接运行 exe可能因权限失败 $exePath $($package.InstallLocation)\Codex.exe if (Test-Path $exePath) { try { Start-Process $exePath Write-Host ✓ 已通过直接路径启动 -ForegroundColor Green } catch { Write-Host ! 自动启动失败请手动启动 -ForegroundColor Yellow Write-Host 1. 按 Win 键搜索 ChatGPT -ForegroundColor Cyan Write-Host 2. 或双击桌面快捷方式 -ForegroundColor Cyan Write-Host 3. 或在文件夹中运行: $exePath -ForegroundColor Gray } } } } Write-Host n -ForegroundColor Green Write-Host ✓ 修复完成 -ForegroundColor Green Write-Host n -ForegroundColor Green Write-Host • 损坏的配置文件已备份 -ForegroundColor Cyan Write-Host • 缓存已清理 -ForegroundColor Cyan Write-Host • 应用已重置 -ForegroundColor Cyan Write-Host • 已自动生成全新默认配置 -ForegroundColor Cyan Write-Host n如果问题仍然存在请重启电脑后再运行此脚本。 -ForegroundColor Yellow Read-Host n按 Enter 退出那么有老铁问了powershell ISE 管理员怎么启动终端直接搜索放大镜或则win键