naming file/folder as "con"

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Just for curiosity sake, why cannot we rename any file/ folder as "con" in
XP? are there other names / patters that we cannot name a file/folder with ?

Thanks.
 
"Microsoft, “File Name Conventionsâ€, MSDN, Apr 2002."

Windows’ particular syntactic restrictions on directory
entry names are as follows:
• A name may not be null.
• A name may not contain any control characters (those
with Unicode value less than 32).
• A name may not contain any of the following reserved
characters: " * / : < > ? \ |
• A name may not end with a space or a period.
• A name may not match any of the following reserved
strings (where n is any decimal digit): AUX, COMn,
CON, CONIN$, CONOUT$, LPTn, NUL, or PRN.
Furthermore, for purposes of determining whether two
names are identical, character case is ignored.

These names are reserved for devices. Also see here for other restrictions:

http://msdn.microsoft.com/library/default.asp?url=/library/en-us/fileio/fs/naming_a_file.asp

John
 
Also.

CON stands for CONsole, the keyboard (input) and the display (output).


Reserved Names (reserved device names)

[[Do not use the following reserved device 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 by an extension, for example, NUL.tx7.

Windows NT: CLOCK$ is also a reserved device name. ]]
from...
Naming a File
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/fileio/fs/naming_a_file.asp

--
Hope this helps. Let us know.

Wes
MS-MVP Windows Shell/User

In
 
Thu, 9 Mar 2006 17:09:27 -0800 from Prasanna
Just for curiosity sake, why cannot we rename any file/ folder as "con" in
XP? are there other names / patters that we cannot name a file/folder with ?

In the old days of DOS, "con" was a special filename meaning the
console i.e. the keyboard/screen for input/output respectively.
"prn" was a special filename meaning the printer. There were others:
com1 through com4 and aux, if I remember correctly.

Even though everyone tells us there is no more DOS, apparently the
command line still recognizes at least some of those filenames as
special, and therefore the file system won't let you create files
with those names.
 
Even though everyone tells us there is no more DOS, apparently the
command line still recognizes at least some of those filenames as
special

copy con for one. ;-)

---------------------
Microsoft Windows XP [Version 5.1.2600]
(C) Copyright 1985-2001 Microsoft Corp.

C:\>copy con "%userprofile%\Desktop\note.txt"
Hi, Stan
This still works, doncha see.
^Z
1 file(s) copied.

C:\>
---------------------

I found just one reference to copy con in an XP MSKB article.

How to troubleshoot problems that you may experience when you try to print
to a local printer by using Office programs in Windows XP
http://support.microsoft.com/kb/870622

Here are a few DosDevices that I found in my registry.

HKEY_LOCAL_MACHINE\HARDWARE\DEVICEMAP\
PARALLEL PORTS
Value Name: \Device\Parallel0
Data Type: REG_SZ
Value Data: \DosDevices\LPT1

Value Name: \Device\Parallel0.4
Data Type: REG_SZ
Value Data:\DosDevices\LPT1.4

HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\
Session Manager\DOS Devices
Value Name: AUX
Data Type: REG_SZ
Value Data: \DosDevices\COM1

Value Name: MAILSLOT
Data Type: REG_SZ
Value Data: \Device\MailSlot

Value Name: NUL
Data Type: REG_SZ
Value Data: \Device\Null

Value Name: PIPE
Data Type: REG_SZ
Value Data: \Device\NamedPipe

Value Name: PRN
Data Type: REG_SZ
Value Data: \DosDevices\LPT1

Value Name: UNC
Data Type: REG_SZ
Value Data: \Device\Mup

HKEY_LOCAL_MACHINE\SYSTEM\MountedDevices
Value Name: \DosDevices\A:
Value Name: \DosDevices\C:
Value Name: \DosDevices\D:
Value Name: \DosDevices\E:
Value Name: \DosDevices\F:

Introduction to MS-DOS Device Names
http://msdn.microsoft.com/library/d..._9a0ea03a-898f-408a-9bce-e1855da47016.xml.asp

Local and Global MS-DOS Device Names
http://msdn.microsoft.com/library/d..._8f1d44af-b30c-434c-97ab-e5de5db16f07.xml.asp

Object Names
http://msdn.microsoft.com/library/d..._0efe70aa-395a-4231-a2cd-1b7ea83c4873.xml.asp

How to restore the system/boot drive letter in Windows
http://support.microsoft.com/default.aspx?scid=kb;en-us;223188

--
Hope this helps. Let us know.

Wes
MS-MVP Windows Shell/User

In
 
Thu, 9 Mar 2006 21:30:55 -0700 from Wesley Vogel <123WVogel955
@comcast.net>:
(I wrote the above, though for some reason it wasn't attributed.)
copy con for one. ;-)

Yes, the MSDN URL you provided calls CON and PRN and the others
devices, which makes sense.
 
(I wrote the above, though for some reason it wasn't attributed.)

Since I replied to you, Stan, consider it attributed to you. ;-)

Write it off as me being a top poster.
 
Back
Top