The “CON” Folder

I just received a funny email today, reading:

YOU WON’T BELIEVE THIS !!!!!!!! An Indian discovered that nobody can create a FOLDER anywhere on the computer which can be named as “CON”. This is something pretty cool…and unbelievable… At Microsoft the whole Team, including Bill Gates, couldn’t answer why this happened!


What is funny about it is that people forward emails without research or verification.

As a programmer and as most programmers know, the “CON” is a special device name which stands for console. There are many other reserved devices names in the DOS/Windows OS, such as: AUX, NUL, LPT1, COM1, etc….

However, you would be able to create use such names if you pass a complete file as: “\\.\c:\con”. As an example, follow these steps:

  1. Start -> Run -> Cmd
  2. type: “notepad \\.\c:\con.”
  3. now go to “My Computer” -> “C:” and notice the file named “CON”
  4. Notice that you won’t be able to delete that file simply by selecting it and pressing DEL. If you ask why, it is because (again) Explorer is passing the name “CON” to the operating system’s DeleteFile() API and not its full name
  5. Now to delete this file, simply type “del \\.\c:\con.” in the command prompt

If you want another “CON” (console) trick, here’s one that allows you to create a text file without using notepad or any other text editing tools:

  1. Go to command prompt and type:
  2. copy con hello.txt
  3. start typing anything you want here, for everything you type here will go into the “hello.txt” file
  4. When you want to finish, simply press CTRL+Z (which will show as ^Z on the screen) and press ENTER

If you wonder what’s the CTRL+Z (aka ^Z) it simply marks the EOF (End Of file).

4 thoughts on “The “CON” Folder

  1. Hi Elias,

    I laughed so hard when I first received said email too. I even replied to the guy who sent it saying that I discovered another trick and used the same text as the email, replacing CON with LPT1 😛

    On the other hand, regardless of the fact it was a bad idea to have globally named devices in the first place, don’t you think that it is stupid of explorer to blindly pass the name? or maybe it was stupid of the API to have special magic values?

    Take for example in UNIX, devices are in the special /dev/ folder, so you won’t accidentaly name your file /dev/hda1 since, as a user, you don’t even have access to write in that location. But since windows does not have this special centralized device location, only a handful of global reserved names, it makes it weird from a consistency point of view.

    If they just couldn’t make it without the global device names, at least they should have had different API calls, or at least a flag that specifies that I’m trying to operate on a device instead of a file.

    Anyway, some decisions they make at Microsoft just don’t make sense to me 🙂


  2. Hey,

    I think they kept that for backward compatibility issues. Back in DOS you had to “TYPE file.txt > LPT1” and you got it printed out.

    They do have a way to access devices rather than files, and it is through the \\.\ path prefix.
    For example, to open C: partition in a hex viewer, you simply have to open the “\\.\c:” file!

  3. hey thnks i have created that folder name “con” nw i think that i must keep some vvi files to this bcz one can not easily delete this folder can u help me in that i tried my best by using xcopy by changing directory but all goes in vain……..

    help me plz
    my id

  4. thanks for the info and allow me to add few notes too
    to create con folder u can use also the md command:
    “md \\.\c:\con”
    to delete it use:
    rd /s \\.\c:\con”
    to copy files inside the folder use copy command
    from cmd prompt type:
    “copy test.txt c:\con\test.txt”

    ya3tik el 3afyi ya zalami 😛
    best regards

Leave a Reply