@echo off setlocal EnableExtensions rem Launch the official Codex Windows app with Git integration disabled. rem The environment changes are limited to this process tree. set "CODEX_INSTALL=" for /f "usebackq delims=" %%I in (`powershell.exe -NoProfile -Command "$p=Get-AppxPackage -Name OpenAI.Codex -ErrorAction SilentlyContinue; if($p){$p.InstallLocation}"`) do set "CODEX_INSTALL=%%I" if not defined CODEX_INSTALL ( echo The official Codex app is not installed. pause exit /b 3 ) set "CODEX_EXE=%CODEX_INSTALL%\app\ChatGPT.exe" if not exist "%CODEX_EXE%" ( echo Codex executable was not found: echo %CODEX_EXE% pause exit /b 4 ) if /i "%~1"=="--check" ( echo Codex Git-disabled launcher is ready. exit /b 0 ) powershell.exe -NoProfile -Command "$items=Get-Process -Name ChatGPT -ErrorAction SilentlyContinue; foreach($item in $items){if($item.Path -like '*\WindowsApps\OpenAI.Codex_*\app\ChatGPT.exe'){exit 2}}; exit 0" set "RUNNING_CHECK=%ERRORLEVEL%" if "%RUNNING_CHECK%"=="2" ( echo Codex is still running. echo Exit Codex completely from the system tray, then run this file again. echo Chat history will be preserved. pause exit /b 2 ) if not "%RUNNING_CHECK%"=="0" ( echo Unable to determine whether Codex is already running. pause exit /b 5 ) set "GIT_DIR=NUL" set "GIT_OPTIONAL_LOCKS=0" start "" "%CODEX_EXE%" exit /b 0