Windows 7 Tips


How to create a CON folder in windows ?


Have you ever tried to create a folder (in a Windows System) with the name as - 
CON ? 

If yes, then you would not have succeeded in doing that as an error message (as illustrated below) would have advised you to rename the folder.


Error Message Suggesting To Rename The Folder

So, how to create it ? And, first of all, why can't we create the folder with this name ?

The truth is, not only con but a whole series of character sets like - PRN, AUX, CLOCK$, NUL, COM1, COM2, COM3, COM4, COM5, COM6, COM7, COM8, COM9, LPT1, LPT2, LPT3, LPT4, LPT5, LPT6, LPT7, LPT8, LPT9 (and more) can't be allocated as folder names. 

The real reason is that these character sets like con, prn, lpt1..lpt9,... etc are underlying devices back from the time when DOS was written. So if you are allowed to create such folders, there will be an ambiguity in the system regarding where to write the data when the information is supposed to be written to the specified devices (having names as mentioned above).


In other words, if one wants to print something, internally what windows tries to do is -- it writes the data to the folder prn (virtually you can call it a folder or basically a storage location, i mean prn, con, etc are virtual storage locations in device level). So if we were able to create con folder, windows would get confused about where to write the data: to actual con folder (which is already present in the system but not accessible to the ordinary user) or the fake one (which we are going to learn right now).


So, to create the folder anyway, go to run in windows or press the buttons Windows + R. Then, type cmd and press enter.

C:\> md \\.\c:\con 


Ok, now don't panic as this folder won't affect your system's integrity.

Now again, try to delete the folder. Well again, you can't delete it !!

Then open the command prompt again.

Type the following -


C:\> rd \\.\c:\con

The folder gets deleted !!

Explanation : Let us now have a glance at how we were able to create it.

This whole process is just because of the UNC Path

http://en.wikipedia.org/wiki/Universal_Naming_Convention)


The Universal Naming Convention, or UNC, defines a common syntax to describe the location of a network resource, such as a shared file, directory, or printer. Since, these conventions didn't exist under pure DOS, they are not backward compatible.

The UNC syntax for Windows systems is as follows - 

\\RemoteHost\sharedfolder\resource 


where RemoteHost is the computer name / IP address of the computer that you wish to connect through remotely for accessing a shared folder. The rest is the path. 

(Here \\remotehost\drive:\con doesn't make sense anyway,


because without having a process on the remote host, there is no current 'console'). It would be a security hazard as well, having the serial and parallel ports accessible for everyone who is allowed to read or write in any single directory.

The "." in the command \\.\c:\con suggest the local server.

And the c: in the \\.\c:\con suggests the path where you want to create the folder. 


Now, you are pointing to your own computer. Since, you have all privileges on every folder of your computer, you can easily create it.

Now its your turn to con others on this trick. :)

0 comments:

Post a Comment