Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

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?

share|improve this question
3  
NUL is a system reserved word; see this Wikipedia article. A file named NUL should never exist on the filesystem; this may be caused by buggy software. You may be able to remove it using the DELETE command using Command Prompt. –  DragonLord May 11 '11 at 17:30
7  
@DragonLord: The filesystem doesn't have a problem with such names; for example, you can create such files within a POSIX environment. (One can find aux.c and similar names in software source code.) It's purely the Win32 API that manages these "device names". –  grawity May 12 '11 at 5:17
    
Thanks for clarifying, @grawity. –  DragonLord May 12 '11 at 12:02

2 Answers 2

up vote 41 down vote accepted

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".

share|improve this answer
    
Thanks! That worked! Also, thanks for the great reference to the authoritative documentation. I found something in a web search that was very similar, but did not work. That suggestion had a . in place of the ?. –  Greg Mattes May 11 '11 at 20:12
1  
@Greg: Sure! The documentation was @DragonLord's help. :-) And yeah, putting . instead of ? doesn't quite do the same thing -- the question mark prevents further processing by the subsystem, whereas the period means "the current machine"... not quite the same thing, although it's definitely confusing. :) –  Mehrdad May 11 '11 at 20:23
1  
I'm not sure it actually means that. The \\.\ prefix is for the device namespace, but there is no explicit mention that . has the same meaning ("current X") as it does for directory names. –  grawity May 12 '11 at 5:15
    
@grawity: Whoops good point, it's an alias for the \DosDevices\ namespace, my bad. –  Mehrdad May 12 '11 at 5:44
1  
As an alternative to above solution if your working directory is already the directory with the nul file, you can: del "\\?\%CD%\nul" The %CD% part is expanded to the working directory and the double quotation marks (") make it all handle also pathnames with "odd" symbols, e.g. "\\?\C:\path,with\comma\nul". –  HenrikB Sep 7 '13 at 15:09

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.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.