Guide · Updated 21 October 2026 · By the makers of Sessions Pro for Codex

Two Codex accounts, on Windows.

A work account in one window and a personal one in the next, with one environment variable. Commands tested on Windows 11 in PowerShell, cmd and Windows Terminal.

Short answer: give each account its own CODEX_HOME folder. In PowerShell, create $HOME\.codex-work, run $env:CODEX_HOME = "$HOME\.codex-work", then codex, and sign in with the second account. A new window without the variable keeps using %USERPROFILE%\.codex and your first account. That separates the command line; the ChatGPT desktop app still holds one account at a time, which is what Sessions Pro for Codex adds on Windows.

Free 1-hour preview once you've signed in to a profile. For Windows 10 or 11 with the ChatGPT app from the Microsoft Store.

How does Codex decide which account you're on?

The Codex CLI doesn't keep a login per window. It keeps one login per folder: CODEX_HOME, which is %USERPROFILE%\.codex on Windows unless you set it. That folder holds auth.json (the login), config.toml (settings, including MCP servers) and your session history. One folder, one account.

The ChatGPT desktop app from the Microsoft Store (its package is OpenAI.Codex) uses the same %USERPROFILE%\.codex for its Codex data, so by default codex in a terminal and Codex in the app share one login. ChatGPT's built-in account switcher doesn't change that: it works on chatgpt.com and doesn't touch the CLI's login (more on the switcher).

If you installed the CLI yourself (for example with npm install -g @openai/codex), codex is on your PATH. The Store app also ships its own codex.exe; this finds it:

Join-Path (Get-AppxPackage OpenAI.Codex).InstallLocation 'app\resources\codex.exe'

How do you set up a second account in PowerShell?

  1. Create a folder for the second account. Codex won't create it for you.
    New-Item -ItemType Directory -Force "$HOME\.codex-work" | Out-Null
  2. Point CODEX_HOME at it and start Codex.
    $env:CODEX_HOME = "$HOME\.codex-work"
    codex
    Sign in with the second account when asked. You do this once per folder.
  3. Use both. Every codex started from that window now uses .codex-work. Open a new PowerShell window and plain codex is back on your first account. Both can run at the same time.

To check where a window stands: $env:CODEX_HOME prints the folder (empty means the default), and codex login status answers Logged in using ChatGPT or Not logged in.

How do you make it one word?

Add a function to your PowerShell profile (notepad $PROFILE; create the file if it doesn't exist):

function codex-work {
    $previous = $env:CODEX_HOME
    $env:CODEX_HOME = "$HOME\.codex-work"
    try { codex @args } finally { $env:CODEX_HOME = $previous }
}

codex-work runs Codex in the work account and then puts the window back the way it was, so a later plain codex in the same window still uses your first account. Add one function per account.

Windows Terminal: add a profile per account and set its Command line to:

powershell.exe -NoExit -Command "$env:CODEX_HOME = Join-Path $HOME '.codex-work'; codex"

Name it something like “Codex (work)” and give it its own tab color, so you can see which account a tab uses.

cmd: use the quoted form of set, so no stray space ends up in the value:

mkdir "%USERPROFILE%\.codex-work"
set "CODEX_HOME=%USERPROFILE%\.codex-work"
codex

What should you watch out for?

  • Don't use setx. A user-level CODEX_HOME is inherited by every program you start afterwards, so you'd be back to one account, just a different one. Set it per window, function or Terminal profile.
  • WSL is a separate login. Inside WSL, ~ is your Linux home, so codex there uses its own ~/.codex, not the Windows one. Use export CODEX_HOME=… there as on Linux.
  • codex logout clears the current folder. With the default folder, that signs out every codex using it and, by default, the desktop app's Codex. See why codex logout signs you out everywhere.

Forgot to create the folder? Codex stops with Error loading configuration: CODEX_HOME points to "C:\\Users\\you\\.codex-work", but that path does not exist. Create it and try again.

What to copy: config.toml if you want the same settings in both (Copy-Item "$HOME\.codex\config.toml" "$HOME\.codex-work\"). Not auth.json, which is the login. Leave each folder's history where it is.

What about the ChatGPT desktop app?

CODEX_HOME separates the command line only. The desktop app keeps its own data and %USERPROFILE%\.codex, so it still holds one account at a time. On a Mac you can make a second copy of the app by hand; on Windows the app comes from the Microsoft Store and lives in a protected package folder, so that route isn't open.

The free option is a second Windows user account: each user gets their own app data and their own .codex. It's right for two people sharing a PC, and slow for one person switching between work and personal all day.

Sessions Pro for Codex runs each account as its own copy of the ChatGPT app in your own Windows account: its own window, titled with the profile name, with its own taskbar button and color, login, chats, Codex threads and settings. “Codex CLI in Terminal” opens a terminal with that profile's own CODEX_HOME, so the command line is signed in to the same account as the window.

Sessions Pro for Codex on Windows: four profiles, Work selected, with the Open and Codex CLI in Terminal buttons
CODEX_HOME by handSecond Windows userSessions Pro for Codex
Two CLI accounts at once✓One per Windows user✓
Desktop app per account✕✓✓
Both apps on screen together✕✕ Switch users✓
CLI signed in to the same account as the appOnly for .codex✓✓ Every profile
CostFreeFree$24.99 one-time

We make Sessions Pro for Codex.

Sessions Pro for Codex
$24.99one-time

Free 1-hour preview once you've signed in to a profile. For Windows 10 or 11; also available for Mac.

FAQ

How do I use two Codex accounts on Windows?

Give each account its own CODEX_HOME folder. In PowerShell, create it with New-Item -ItemType Directory -Force "$HOME\.codex-work", run $env:CODEX_HOME = "$HOME\.codex-work", then codex, and sign in once. A new window without the variable keeps using %USERPROFILE%\.codex and your first account.

Where does Codex keep its login on Windows?

In auth.json inside CODEX_HOME, which is %USERPROFILE%\.codex unless you set it. The ChatGPT desktop app from the Microsoft Store uses the same folder for its Codex data, so by default the app and the command line share one login.

Can I run two copies of the ChatGPT app on Windows?

Not by copying it: the Store app lives in a protected package folder. A second Windows user account gives you a separate app with its own login. Sessions Pro for Codex runs each account as its own copy of the ChatGPT app, side by side, in your own Windows account.

Sessions Pro for Codex is made by LEX GLOBAL IT S.R.L. and is not affiliated with, endorsed by or sponsored by OpenAI. It runs the official ChatGPT app with accounts you already have, and OpenAI's terms apply to each account. ChatGPT and Codex are trademarks of OpenAI.