How do I remove a file named "NUL" on Windows?

I have a Windows XP box (NTFS filesystem) on which I found a file named NUL. I have not been able to remove this file in any usual way. The file appears to be owned by Administrator in the SYSTEM group, unlike any other file in the same directory (the other files are owned by my user id).

How do I get rid of this file? Where did it come from?


Solution 1:

Try

Del \\?\C:\My\Path\NUL

in the command prompt.

See this Microsoft Support article for details: You cannot delete a file or a folder on an NTFS file system volume, under "Cause 5: The file name includes a reserved name in the Win32 name space".

Solution 2:

Alternatively if you have Cygwin installed, you may want to know, that it has no problem with such files or folders. Particularly,

rm -r /cygdrive/c/path/to/the/file/or/folder/you/want/to/delete

typed in the Cygwin terminal deletes the file or folder named nul or a folder, containing it. This is also applicable to other special file names such as CON, PRN, AUX, COM1, COM2, COM3, COM4, COM5, COM6, COM7, COM8, COM9, LPT1, LPT2, LPT3, LPT4, LPT5, LPT6, LPT7, LPT8.