I cannot delete a file named con or nul.

A. The syntax \\.\ does not work with a file named con or nul .

In fact, no Win32 tool may delete these files.

A solution is to use non-Win32 tools.

For instance, the Resource Kit contains POSIX utilities such as rm.exe, which allows to delete these files:

c:\NTReskit\posix\rm con

Note: the files may have been created with a tool such as notepad or more, using the streams notation. For instance, type "notepad con:foo" on an NTFS partition, or "more < any_file > nul:bar"

There is an easier way, without using reskit and non-native subsystems which is to rename the file then just delete:

C:\> ren \\.\c:\nul. file
C:\> del file


Hide comments

Comments

  • Allowed HTML tags: <em> <strong> <blockquote> <br> <p>

Plain text

  • No HTML tags allowed.
  • Web page addresses and e-mail addresses turn into links automatically.
  • Lines and paragraphs break automatically.
Publish