Can't create a folder named com1

I find it interesting that in 20+ years of working in technology, most of those years working with Windows systems, that yesterday was the first day I ran into this issue: Windows cannot create a folder named "com1".

As you can probably guess, we have a lot of scripts and tools to handle various automation tasks. Some of those tasks create files and folders on certain folders based on certain naming conventions. Yesterday one of those scripts' logic directed it to create a folder named "com1" and the script failed miserably. It couldn't finish. Windows was throwing an error and the script couldn't complete. Thankfully this wasn't a script in which failure impacted anything operational, so it wasn't a big deal, but rather just more annoying.

Come to find out, "com1" is a Windows reserved name and cannot be used in a file or folder name. Go ahead - try it. Try to create a folder on your PC with that name and watch it fail. Apparently COM0-COM5 and LPT0-LPT5 are all reserved words. There are probably other reserved words too but a quick Google search didn't give a concise list from any source that I thought would be authoritative.

So, the take-away: If you ever run into file/folder creation errors and nothing stands out as wrong in the script, check whether it might be trying to use a Windows reserved word.

No Comments