This page shows the source for this entry, with WebCore formatting language tags and attributes highlighted.

Title

Reserved filenames in Windows

Description

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 <c>:</c> and <c>?</c> and <c>*</c>, but I didn't know that otherwise innocuous-looking names like <c>aux.txt</c> and <c>con.txt</c> are verboten. I learned about this from the article <a href="https://threadreaderapp.com/thread/1058676834940776450.html" source="Thread Reader" author="foone">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 […]</a>, 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 <a href="https://docs.microsoft.com/en-us/windows/desktop/fileio/naming-a-file" source="Windows Dev Center">Naming Files, Paths, and Namespaces</a>, referenced from the article above <bq>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.</bq> While it's possible that this is only a recommendation, <c>Explorer.exe</c> does not allow these filenames at all, as shown in the screenshot below (take on an up-to-date Windows 10 Enterprise installation). <img src="{att_link}con_txt_is_illegal.png" href="{att_link}con_txt_is_illegal.png" align="none" scale="50%"> I tried <c>nul</c> and <c>con</c> with several different extensions (<c>bmp</c>, <c>exe</c>, <c>txt</c>, <c>doc</c>, 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 <c>Explorer</c> or by <c>CreateFileEx</c>?) 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.