Your browser may have trouble rendering this page. See supported browsers for more information.

|<<>>|68 of 265 Show listMobile Mode

Reserved filenames in Windows

Published by marco on

Did you know that there are some filenames you’re not allowed to use in Windows?

I knew that there are characters that you cannot use in a path, like : and ? and *, but I didn’t know that otherwise innocuous-looking names like aux.txt and con.txt are verboten.

I learned about this from the article It is 2018 and this error message is a mistake from 1974. This limitation, which is still found in the very latest Windows 10, dates back to […] by foone (Thread Reader), which has a pretty click-bait–y title and is quite long, to boot. The author includes a lot of detail and conjecture about how it is that Windows 10 still has some forbidden/reserved filenames (and then takes half of it back or corrects it in several long footnotes).

Instead of citing the article, I included the upshot that I found interesting, which is better explained in the official Microsoft documentation Naming Files, Paths, and Namespaces (Windows Dev Center), referenced from the article above

“Do not use the following reserved names for the name of a file:

“CON, PRN, AUX, NUL, COM1, COM2, COM3, COM4, COM5, COM6, COM7, COM8, COM9, LPT1, LPT2, LPT3, LPT4, LPT5, LPT6, LPT7, LPT8, and LPT9. Also avoid these names followed immediately by an extension; for example, NUL.txt is not recommended.”

While it’s possible that this is only a recommendation, Explorer.exe does not allow these filenames at all, as shown in the screenshot below (take on an up-to-date Windows 10 Enterprise installation).

I tried nul and con with several different extensions (bmp, exe, txt, doc, etc.) and none of them are allowed. I have not checked whether this restriction applies to files created programmatically (i.e. is the restriction enforced by Explorer or by CreateFileEx?)

I’m just wondering how I’ve never noticed or heard of this before. Talk about a restriction that Microsoft was wise never to fix because people don’t run into it! I guess the filenames are so short I’ve never tried to use them.