I have a file named con.php. I tried to remove it through the Windows command line but it returns an error:

Syntax for filename, directory name, or volume label is incorrect.

marked as duplicate by phuclv, Toto, Twisty Impersonator, bertieb, DavidPostill windows-10 Oct 20 '18 at 17:40

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.


Assuming the full path is c:\foo\bar\con.php, then

del \\?\c:\foo\bar\con.php

Due to ancient MS-DOS "compatibility" concerns, con is the console, yes even with an extension. This is in a layer above the file system.

The \\?\ prefix suspends DOS-compatible parsing and hands the rest of the spec directly to the file system.

Link to explanation: https://docs.microsoft.com/en-us/windows/desktop/FileIO/naming-a-file#win32-file-namespaces

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