Skip to content

Instantly share code, notes, and snippets.

@Loongphy
Last active May 19, 2026 08:46
Show Gist options
  • Select an option

  • Save Loongphy/12a1e2ece481a8ba6dae7dc16a2192ac to your computer and use it in GitHub Desktop.

Select an option

Save Loongphy/12a1e2ece481a8ba6dae7dc16a2192ac to your computer and use it in GitHub Desktop.
Windows Codex Remote Control
function codex-lock {
param(
[int]$Seconds = 90
)
$cfg = "$HOME\.codex\config.toml"
# 先确保 codex CLI 可以写配置
attrib -R "$cfg"
codex features enable remote_control
$pkg = Get-AppxPackage -Name OpenAI.Codex
$manifest = Get-AppxPackageManifest -Package $pkg.PackageFullName
$app = @($manifest.Package.Applications.Application)[0]
$aumid = "$($pkg.PackageFamilyName)!$($app.Id)"
try {
attrib +R "$cfg"
Start-Process "shell:AppsFolder\$aumid"
Start-Sleep -Seconds $Seconds
}
finally {
attrib -R "$cfg"
}
}
@Loongphy
Copy link
Copy Markdown
Author

Loongphy commented May 18, 2026

single line:

$Seconds=90;$cfg="$HOME\.codex\config.toml";$me=[System.Security.Principal.WindowsIdentity]::GetCurrent().Name;attrib -R "$cfg";icacls "$cfg" /remove:d "$me" *> $null;codex features enable remote_control;$pkg=Get-AppxPackage -Name OpenAI.Codex;$manifest=Get-AppxPackageManifest -Package $pkg.PackageFullName;$app=@($manifest.Package.Applications.Application)[0];$aumid="$($pkg.PackageFamilyName)!$($app.Id)";try{attrib +R "$cfg";Start-Process "shell:AppsFolder\$aumid";Start-Sleep -Seconds $Seconds}finally{attrib -R "$cfg"}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment