nul,con,aux,prn,lpt etc. Are reserved dos devices. When we try to create any file or folder with this name, we fail to create it and it results some kind of weird error.

But recently I ran the command md con\ in cmd and a directory named con was created (not con\)! I could normally copy and paste files in it, but when tried to delete it it resulted an error in windows explorer. But when I deleted that using command rd con\ it got deleted successfully.

I am wondering why we cannot create files or folders with these reserved names in windows explorer but CMD is successfully doing this?

  • 1
    md command makes directories including intermediate directories. eg md c:\fldr1\fldr2\fldr3 will make all three folders so you told it to make one directory in a multi directory command format. Windows has rules for filenames so all programs can access all files. A program can opt in to less restrictive rules if its sure no other program needs access to the file. The NTFS file system will store files from any other operating system. It up to the OS making the files to enforce it's rules so its programs can read it.
    – Mark
    Jun 13, 2020 at 19:35
  • 2
    CMD internal commands support less restrictive rules by prefacing paths with \\?\ . So dir \\?\c:\windows.
    – Mark
    Jun 13, 2020 at 19:38
  • 2
    Explorer has it own restrictive rules that aren't windows. Explorer won't allow spaces as the last character even though its a legal windows name, it just removes them..
    – Mark
    Jun 13, 2020 at 19:40
  • youtube.com/watch?v=bC6tngl0PTI is a pretty good overview. Jun 14, 2020 at 9:35

1 Answer 1


Reserved File Names

why we cannot create files or folders with these reserved names in windows explorer but CMD is successfully doing this?

Explorer and cmd are different programs and in this case Explorer is more restrictive than maybe it needs to be.

According the the official Microsoft documentation the list of restricted names only applies to files and not to folders:

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. For more information, see Namespaces.

(emphasis mine)

Source Naming Files, Paths, and Namespaces - Win32 apps | Microsoft Docs

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .