方案
永久允许当前用户运行本地脚本
如果你经常需要运行 Codex,可只修改当前用户的执行策略,不影响整台电脑的其他用户。
1
以管理员身份打开 PowerShell:右键点击开始菜单,选择 Windows PowerShell(管理员)。
2
执行下面命令。
3
提示时输入 Y 确认。
Set-ExecutionPolicy -ExecutionPolicy RemoteSigned -Scope CurrentUser
4
关闭管理员窗口,重新打开普通 PowerShell。
5
codex --profile openrouter-free
问题
Windows PowerShell 提示禁止运行脚本
运行 codex --profile openrouter-free 时,PowerShell 报错无法加载 codex.ps1。
常见提示包含:因为在此系统上禁止运行脚本、about_Execution_Policies、PSSecurityException、UnauthorizedAccess。
无法加载文件 C:\Users\...\AppData\Roaming\npm\codex.ps1PSSecurityException / UnauthorizedAccess