You have the Codex desktop app installed on Windows. You use it every day to chat about your project folders. But every time you want to add a new folder, you go through the same friction: you open Codex, look for how to add the project, navigate through the app's file explorer until you find the folder, and select it. Five clicks where there could be one.
The natural flow would be the opposite: have the folder in your Windows Explorer, right-click, choose "Open with Codex", and the folder appears instantly in your Projects panel. That option doesn't come out of the box. The good news: you can add it in 30 seconds without writing a single line of code yourself.
This guide is aimed at people who are not developers. The idea is not for you to understand every command or open a console. The idea is for you to copy a prompt, paste it to your AI agent, and let it do everything. You only check at the end that it works.
What you will get
After applying the recipe, you will have:
- An "Open with Codex" option in the right-click menu of any folder in Windows Explorer.
- The option shown on the first screen of the menu, not hidden under "Show more options".
- One click → the folder is automatically added to the Projects panel of your Codex app.
It requires no administrator permissions. All the change lives in your user profile and can be reverted with a single command if you ever no longer want it.
Principle: the Windows context menu is modifiable. If an app you use every day isn't there, you can add it yourself.
What you will need
Before copying the prompt, make sure you have three things:
- The OpenAI Codex app installed from the Microsoft Store or from developers.openai.com/codex/app. If you don't have it yet, install it first — the rest won't work without the app.
- An AI agent able to run commands on your computer. Any of these will do: Claude Code, Cursor (Agent mode), Windsurf (Cascade), GitHub Copilot Workspace, or whichever your team uses. What matters is that it can run PowerShell commands — not that it's a purely conversational chatbot.
- Windows 11. On Windows 10 the steps are slightly different and this recipe doesn't apply as-is.
Principle: an agent that can run commands does in seconds what would take you half an hour of reading tutorials. Taking advantage of it is the difference between technical productivity and assisted productivity.
The prompt — copy it and paste it into your agent
Open the chat with your agent. Paste the block below as is. You don't need to change anything — the prompt already includes all the details the agent needs so it doesn't make mistakes.
I want to add an "Open with Codex" option to the Windows 11 File Explorer right-click menu, so that when I right-click any
folder and choose that option, the folder is automatically added to the
Projects panel of my Codex desktop app (OpenAI's official app,
installed from the Microsoft Store, AUMID OpenAI.Codex_...!App).
The option needs to appear on the FIRST screen of the context menu,
not hidden under "Show more options". I also don't want to request
administrator permissions — everything must live in HKCU.
IMPORTANT RULE — IDEMPOTENCY:
This prompt may be run SEVERAL times on the same machine (because I
pass it again, because I update Codex, because you resume a broken
session). Your goal is not to "add entries" but to "leave the system in the correct state":
- In the end there must be EXACTLY ONE "Open with Codex" entry in the
folder context menu (one for right-clicking on a folder, another for
clicking on the background inside a folder — but both with the same
name and behavior).
- If a previous installation already exists with the correct content:
DO NOT touch anything, just verify and report "it was already fine".
- If a previous installation exists with incorrect or outdated content
(different launcher, old command without -STA, AUMID hardcoded to an
old version, different launcher path): overwrite the values in place —
do not add a new key next to it.
- If you find MULTIPLE keys that look like "Open with Codex"
(e.g. Codex, CodexBeta, OpenWithCodex, OpenAI_Codex created in previous
attempts): delete the extras and keep only the canonical key named
exactly "Codex".
- The canonical key name is "Codex" (no suffixes) and the canonical
launcher name is "%USERPROFILE%\codex_launcher.ps1".
Please do the whole setup automatically, without asking me between steps:
STEP 0 — PRIOR DIAGNOSIS AND CLEANUP OF PARALLEL INSTALLATIONS
- List all subkeys under:
HKCU:\Software\Classes\Directory\shell\
HKCU:\Software\Classes\Directory\Background\shell\
- For each subkey, read its (Default) and its command\(Default).
Mark as "Codex installation" any subkey whose
(Default) contains "Codex" (case-insensitive) OR whose
command\(Default) references OpenAI.Codex, codex_launcher,
or the Codex AUMID.
- If there are subkeys marked with a name different from the canonical
"Codex", DELETE THEM recursively (Remove-Item -Recurse).
- If the canonical "Codex" subkey already exists, do NOT delete it yet
— you will update it in place in step 3.
- Report to me what you found and what you deleted before continuing.
STEP 1 — DETECT THE AUMID DYNAMICALLY
- Do not hardcode the package version. Resolve it with
`Get-AppxPackage | Where-Object Name -eq 'OpenAI.Codex'` and build
the AUMID as `"$($pkg.PackageFamilyName)!App"`.
- If Get-AppxPackage returns nothing, abort and ask me to install Codex
from the Microsoft Store before continuing.
- The launcher itself will re-resolve the AUMID on every run, so it will
not be tied to the current version.
STEP 2 — WRITE THE POWERSHELL LAUNCHER (idempotent: overwrite)
- Canonical path: %USERPROFILE%\codex_launcher.ps1
- If the file already exists, COMPARE its content with the desired content.
If they are identical, don't write (avoids a new modification mark). If
they differ, overwrite.
- Launcher content: use the IApplicationActivationManager API
(CLSID 45BA127D-10A8-46EA-8AB7-56EA9078943C, IID
2e941141-7f97-4756-ba1d-9decde894a3d) to activate the MSIX app,
passing the folder as an argument. DO NOT use
`explorer.exe shell:AppsFolder\...` because from the Registry that
makes Explorer open the folder as a normal window instead of handing it
to Codex as an activation argument.
- The launcher receives -Folder as a parameter, re-resolves the AUMID
via Get-AppxPackage at runtime, instantiates ApplicationActivationManager
via COM, and calls ActivateApplication with (aumid, $Folder, 0, out pid).
STEP 2b — WRITE THE INVISIBLE VBSCRIPT WRAPPER (idempotent)
- Canonical path: %USERPROFILE%\codex_launcher.vbs
- Why this wrapper: if the Registry invokes `powershell.exe` directly,
even if you pass -WindowStyle Hidden, a console flash of about
200-300ms still appears on startup. wscript.exe (the Windows VBScript
engine) is headless by design and NEVER creates a console window. The
.vbs simply invokes the .ps1 from a wscript process, eliminating the
flash entirely.
- Expected content of the .vbs (3 functional lines):
Set sh = CreateObject("WScript.Shell")
folder = WScript.Arguments(0)
cmd = "powershell.exe -NoProfile -WindowStyle Hidden " & _
"-ExecutionPolicy Bypass -STA -File """ & _
sh.ExpandEnvironmentStrings("%USERPROFILE%") & _
"\codex_launcher.ps1"" -Folder """ & folder & """"
sh.Run cmd, 0, False ' 0 = hidden window, False = don't wait
- If the .vbs already exists, compare its content and only overwrite if
it differs.
STEP 3 — REGISTER/UPDATE THE TWO ENTRIES IN HKCU (idempotent)
- Canonical key for right-clicking a folder:
HKCU\Software\Classes\Directory\shell\Codex
(Default) = "Open with Codex"
command\(Default) = wscript.exe "%USERPROFILE%\codex_launcher.vbs" "%1"
- Canonical key for clicking the background of a folder:
HKCU\Software\Classes\Directory\Background\shell\Codex
(Default) = "Open with Codex"
command\(Default) = wscript.exe "%USERPROFILE%\codex_launcher.vbs" "%V"
- Use `New-Item -Force` and `Set-ItemProperty` — both are idempotent
(they overwrite if the key/value already exists).
- Before considering this step done, read the values back with
`reg query` and verify they match what is expected.
- IMPORTANT: the Registry command points to `wscript.exe + .vbs`,
NOT directly to `powershell.exe + .ps1`. The chain is
wscript -> vbs -> hidden powershell -> ps1 -> COM activate.
Any previous installation that invoked powershell.exe directly from the
Registry must be UPDATED to the wscript pattern (that old version caused
the console flash — this one doesn't).
- The -STA flag inside the .vbs is still CRITICAL. Without it, COM
activation fails silently because IApplicationActivationManager requires
the single-threaded apartment.
STEP 4 — ACTIVATE THE CLASSIC WINDOWS 11 MENU (idempotent)
- Key: HKCU\Software\Classes\CLSID\{86ca1aa0-34aa-4e8b-a509-50c905bae2a2}\InprocServer32
- If it already exists with (Default) = "" (empty string), don't touch it
and report "classic menu was already active".
- If it doesn't exist or has another value, create/overwrite it with
(Default) = "" (empty string).
- This removes ALL custom entries from "Show more options" and puts them on
the first screen — it is not exclusive to Codex. Remind me of this
consequence explicitly in the final report.
STEP 5 — RESTART EXPLORER (always)
- Stop-Process -Name explorer -Force; Start-Process explorer
- It is safe to do this even if nothing changed — it takes 2 seconds and
guarantees Explorer rereads the keys.
STEP 6 — FINAL VERIFICATION
- Confirm there is EXACTLY ONE "Codex" key in each of the two context menu
paths. If for any reason you ended up with duplicates, delete them.
- Show me the final values with `reg query`.
- Verify the launcher exists and ends with the line that calls
[CodexLauncher]::Activate.
- Report an explicit summary of what you did:
a) Was it a new installation, an update, or was it already fine and you
only verified?
b) If you cleaned up duplicate/legacy keys, list which ones.
c) Version of the Codex package detected.
- Tell me how to test: right-click on a LOCAL folder (on C:\, not on G:\
or OneDrive if it is virtual) that is NOT already in my Codex Projects
panel, choose "Open with Codex", and check whether it appears in the panel.
- Explicitly WARN me about virtual filesystems: Codex silently ignores paths
that live in Google Drive (G:\ Drive File Stream), OneDrive with Files
On-Demand not synced, or any filesystem that uses placeholders. If I want
to use it with those folders, I have to mark them "Available offline"
first, or use `subst` to map them to a "real" drive letter.
- Give me the exact command to revert everything if I want to uninstall.
Run everything in PowerShell. Don't ask me for confirmation between steps. If
something fails, show me the actual error and propose the next step. Re-running
this prompt a second time on the same machine must be a no-op if everything is
already correct, and a surgical fix if something drifted.
Paste that block to your agent, hit send, and let it work. The whole process takes less than a minute. You'll see the agent run several commands in its terminal — don't be alarmed, it's expected. When it finishes, it will tell you it's ready.
Principle: a good prompt doesn't ask the agent to guess. It gives exact technical details where it's easy to make mistakes, and leaves it free to decide where the choice doesn't matter.
How to verify it worked
When the agent tells you it's done, do this:
- Open Windows Explorer.
- Go to any folder on your local drive (for example, one inside
Documents). - Right-click on that folder. You should see "Open with Codex" among the first options — not under "Show more options".
- Click that option. You won't see any window or flash — the activation goes through a headless VBScript wrapper that is 100% invisible.
- Check your Codex app. The folder you just selected should appear in the Projects panel.
If the folder appears, everything is working. Also try right-clicking the blank background inside an open folder — it should add the folder you're standing in.
If something doesn't work — the two common cases
Case 1 — The option appears but doesn't add the folder to Codex.
Most likely: the folder lives on a virtual filesystem. This happens with Google Drive folders (drive letter G:\ with Drive File Stream), OneDrive with unsynced on-demand files, or any "virtual drive" that shows files without having them physically. Codex doesn't open those paths — it silently discards them.
Quick fix: in the Google Drive or OneDrive client, right-click the folder and mark it as "Available offline". That action physically downloads the files and exposes them as a real path to the system. Then try "Open with Codex" again — it should work. As a quick reference: if you test with a folder inside C:\Users\YourUser\Documents it works, and with the same operation on G:\My Drive\... it doesn't, and now you know why.
Case 2 — The option doesn't appear in the menu.
Ask the agent: "restart Windows Explorer with Stop-Process -Name explorer -Force; Start-Process explorer and show me with reg query whether the two entries in HKCU\Software\Classes\Directory\shell\Codex and HKCU\Software\Classes\Directory\Background\shell\Codex are correct". Nearly always Explorer hasn't read the change yet and a restart fixes it.
Principle: when something doesn't work, before reverting, tell the agent what you see. It will probably fix it in one message.
How to uninstall everything
If you ever no longer want this option, copy this to your agent:
I want to remove the "Open with Codex" context menu entry we added
earlier. Delete the two entries under HKCU\Software\Classes\Directory\shell\Codex
and HKCU\Software\Classes\Directory\Background\shell\Codex, delete the files
%USERPROFILE%\codex_launcher.ps1 and %USERPROFILE%\codex_launcher.vbs, and
restart Explorer.
If you also want, restore the new Windows 11 menu by deleting the key
HKCU\Software\Classes\CLSID\{86ca1aa0-34aa-4e8b-a509-50c905bae2a2}.
But warn me that this will hide ALL custom entries again (from Codex and from
any other editor or tool) behind "Show more options".
The agent will run the revert and report back to you. No residue is left on your system.
Why this pattern is different from other editors
If you've read similar guides for adding VS Code, Cursor or Windsurf to the context menu, you'll notice that recipe is simpler: create a three-line .cmd launcher and register two Registry keys pointing directly to the editor's executable. Codex requires a different path, and it's worth understanding briefly why — because the same pattern applies to other OpenAI or Microsoft apps distributed through the Microsoft Store.
Codex is distributed as a packaged app (MSIX). That means its real executable lives under C:\Program Files\WindowsApps\ with restricted permissions — you can't invoke it directly from the Registry the way you would with a traditional .exe. The official way to "launch" an MSIX app and pass it arguments is through the Windows IApplicationActivationManager API: a COM call that receives the AppUserModelID (a stable identifier pointing to the packaged app) and the argument string. That's why you need a PowerShell launcher — to make that COM call.
There are two other details where it's very easy to make mistakes, and the agent's prompt already covers them:
- The
-STAflag is mandatory. The API requires the "single-threaded" apartment threading model, and PowerShell by default starts multi-threaded when Windows invokes it with-File. Without-STAthe activation fails silently — the API doesn't even throw an exception. - The AUMID changes with every version of the package. Hardcoding it means the recipe stops working the next time Codex updates. That's why the launcher queries
Get-AppxPackageat runtime — it works today, tomorrow, and six months from now without touching anything. - The VBScript wrapper is what eliminates the console flash. If the Registry invokes
powershell.exedirectly, even with-WindowStyle Hidden, a flicker of about 200ms still appears when the console host starts.wscript.exeis headless by design and doesn't create any window, so the chainwscript → .vbs → hidden powershell → .ps1 → COMis 100% invisible to the user.
Principle: the Registry-launcher pattern changes depending on whether the app is a traditional executable or a packaged MSIX app. If your app came from the Microsoft Store, you almost certainly need this variant.
Closing
Once you have "Open with Codex" in your right-click menu, the friction of "adding a folder as a project" disappears. Creating a new folder and starting to work on it with Codex goes from five clicks to one. It's the kind of change that seems small until two weeks pass and you realize it changed the way you organize your projects.
And the entire recipe was made available to you without touching any code, without opening a console, without having to understand PowerShell, MSIX or IApplicationActivationManager. One prompt, copy-paste, visual check. That's the level human-agent collaboration can offer when the prompt is well built.