Fix ERROR_BAD_PATHNAME (0X000000A1) fast
Windows throws this when a path has illegal characters or is too long. Quick fix: check for trailing spaces or broken shortcuts.
Quick answer: Check the path for trailing spaces, colons, or broken shortcuts. Use Command Prompt to find the exact file or folder causing the issue.
Why you're seeing this error
I know this one is annoying. It usually pops up when you try to open a file, run a program, or map a network drive. The error means Windows can't read the path you gave it. I've seen this happen most often with USB drives, old network shares, or when someone pasted a path with a hidden space at the end.
The real trigger? It's almost always a character Windows doesn't like: a trailing space, a colon inside a folder name, or a path longer than 260 characters. Also watch out for broken shortcut links — the .lnk file points to a place that doesn't exist anymore.
Fix steps (start here)
- Check the path for illegal characters. Open File Explorer and navigate manually to where the file should be. Look for any of these in the folder or file name:
\ / : * ? " < > |. Also check for a space at the end of the name. If you see one, rename it without the space. - Run Command Prompt as admin. Type
cmdin the Start menu, right-click it, and choose "Run as administrator". Then type:
cd /d "C:\path\to\your\folder"
Replace the path with the one giving you trouble. If it says "The system cannot find the path specified", the folder doesn't exist or the path is broken. - Test a simpler path. Copy the file to a folder like C:\Test with no spaces or special characters. Try opening it from there. If it works, the original path had a bad character.
- Check the path length. Windows 10 and 11 still have a 260-character limit by default (MAX_PATH). Count characters in the full path. If it's over 260, you can either shorten folder names or enable long paths in Group Policy (Windows Pro only):
Computer Configuration > Administrative Templates > System > Filesystem > Enable Win32 long paths
Set it to Enabled and reboot. - Look at network drives or USB drives. The error often happens when the drive letter changed. Example: you had a USB drive on D:, but now it's on E:. In that case, just update the path or remap the drive.
If the main fix doesn't work
Sometimes the problem is a broken shortcut. Here's how to check:
- Right-click the shortcut (.lnk file) and go to Properties. Look at the "Target" field. Does that path actually exist? If not, delete the shortcut and make a new one.
- The error also shows up when you try to access a folder that was deleted but the shortcut still points there. I've tripped on this myself — it's easy to miss.
Another option: run a quick disk check with chkdsk. Sometimes file system errors mess up the path lookup:
chkdsk C: /f
You'll need to restart the PC for it to run. This fixes folder corruption that could cause the bad path error.
How to prevent it next time
This one is simple but saves headaches. When you name files or folders, stick to letters, numbers, underscores, and hyphens. No spaces at the end. No colons or slashes in the middle. And if you're working with long paths, turn on long path support in Windows right now — it's a one-time setting that stops this error for good.
Also, after you plug in a USB drive, always check the drive letter in File Explorer before running anything from it. It might be different than last time.
Was this solution helpful?