PRB: File Routines Fail with Some File Names (CON, PRN, AUX, CLOCK$, NUL, COM1 - COM9, LPT1 - LPT9)
Q216654
--------------------------------------------------------------------------------
The information in this article applies to:
Microsoft Windows NT Server versions 3.5, 3.51, 4.0
Microsoft Windows NT Workstation versions 3.5, 3.51, 4.0
Microsoft Windows 98
Microsoft Windows 95
Microsoft Windows 2000 Advanced Server
Microsoft Windows 2000 Server
Microsoft Windows 2000 Professional
SYMPTOMS
File creation, deletion, read, write, and manipulation routines fail or behave unpredictably when dealing with a file with one of the following names: CON, PRN, AUX, CLOCK$, NUL, COM1 - COM9, LPT1 - LPT9.
To illustrate this, start a command prompt under Windows 9x or Windows NT. Copy any file to an unused name; for example, Testfile.tmp. Now, type in the command REN testfile.tmp CON.
RESULTS: You get an error that states the file already exists.
CAUSE
This problem is caused by name collision with the reserved device names. These names are reserved by Windows 95, Windows 98, Windows NT, and Windows 2000 for backwards compatibility with MS-DOS, which reserved these names for various devices. If these device names were not reserved, one could no longer use the following standard MS-DOS syntax (from a command prompt) to create a text file:
COPY CON testfile.txt
or the following method to view it:
COPY testfile.txt CON
or the following method to print it:
COPY testfile.txt PRN
or the following method to output text typed from the keyboard to the printer:
COPY CON PRN
RESOLUTION
These names must be avoided when creating file names.
STATUS
This behavior is by design, for backwards compatibility with MS-DOS applications, and is a consequence of the MS-DOS device driver architecture. Because legacy MS-DOS applications, or MS-DOS applications ported to console-mode applications, may explicitly use these reserved file names, these file names must be retained as long as MS-DOS backwards compatibility is required in the Windows family.
MORE INFORMATION
Similar behavior may be observed if special legacy-type device drivers that register other reserved names are loaded (for example, by Config.sys or Autoexec.bat).
REFERENCES
For additional information, please see the following article in the Microsoft Knowledge Base:
Q120716 How To Remove Files with Reserved Names in Windows NT
Additional query words: CON PRN AUX CLOCK$ NUL COM1 COM2 COM3 COM4 LPT1 LPT2 LPT3