When you'll see this error
You're running some app — maybe a legacy tool, a game, or a custom script — and suddenly it crashes with the message: "The flag passed is not correct" and error code 0x000000BA. I've seen this most often with old Visual Basic apps, custom-built software that uses deprecated Windows APIs, or when someone tries to run a 16-bit program on a 64-bit OS. It also happens sometimes with third-party shell extensions that hook into Explorer.
What's actually going on
The error code 0x000000BA is defined as ERROR_INVALID_FLAG_NUMBER in the Windows SDK. It means a program called a Windows function — like CreateFile, DeviceIoControl, or SetFilePointer — and passed a flag that doesn't exist or isn't valid for that function. The culprit here is almost always one of two things:
- Buggy software — The developer hardcoded a flag that's wrong for the current OS version. I've seen this with apps compiled against old Windows 2000 headers that use flags removed in Vista or later.
- Corrupted system files — A critical DLL like
kernel32.dllorntdll.dllgot damaged, and the flag validation logic inside it is broken.
Don't bother checking your hardware or drivers — this isn't a hardware issue. It's purely a software or system integrity problem.
Step-by-step fix
- Identify the triggering program. Check the Event Viewer: press Win + R, type
eventvwr.msc, hit Enter. Go to Windows Logs > Application, look for Error events with source "Application Error" or "Windows Error Reporting". Find the crashing executable name. That's your target. - Update or reinstall that program. If it's a commercial app, check the vendor's site for a newer version. Old software often has known flag bugs for newer Windows. Uninstall it completely, then install the latest version. For custom scripts, check the code — search for
0x000000BAor invalid flag values in the source. - Run SFC and DISM. Open Command Prompt as Administrator. Run
sfc /scannow. Let it finish — it'll take 15-20 minutes. If it finds issues it can't fix, runDISM /Online /Cleanup-Image /RestoreHealthnext. Reboot after both. - Check for corrupt registry flags. Rare but possible. Open Registry Editor (
regedit), back up your registry first (File > Export). Go toHKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Session Manager\SubSystems. Look for any custom "Optional" or "Required" values that reference old subsystem flags. Delete any entries you didn't add yourself — but only if you're sure. If unsure, skip this step. - Compatibility mode as last resort. Right-click the crashing executable, go to Properties > Compatibility. Try running it in Windows 7 or Vista SP2 mode. This sometimes works around bad flag checks in older apps.
If it still fails
You've got a stubborn one. Here's what I'd check next:
- Antivirus interference. Some antivirus hooks system calls and can mangle flag values. Temporarily disable your AV and test. If it works, add an exception for the app.
- Missing Visual C++ runtimes. Old apps often need specific runtime versions. Install all available VC++ redistributables from Microsoft (2005-2022, both x86 and x64).
- Process Monitor trace. Download Procmon from Sysinternals. Set a filter for the crashing process. Look at the last call before the error — it'll show the exact API and flags. Google that flag value to see if it's valid for your Windows version.
If nothing works, the app is simply incompatible with your OS. Accept it and look for a modern alternative. I've spent hours chasing 0x000000BA on ancient accounting software — sometimes you can't fix bad code.