1

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.
phuclv
  • 26,555
  • 15
  • 113
  • 235
sNniffer
  • 111
  • 1
  • 3
  • 1
    msdos? Do you mean cmd.exe? If so try powershell and / or try cmd again with the filename quoted. – Tyson Oct 20 '18 at 01:48
  • no powershell also did not work, return: `del: Can not remove item C: \ admin \ admin \ config \ con.php: Path access 'con.php' has been denied.` – sNniffer Oct 20 '18 at 01:56
  • Did you try quoted? – Tyson Oct 20 '18 at 01:58
  • there's no DOS in Windows 10, and [the Windows cmd is **not** DOS](https://superuser.com/q/451432/241386) – phuclv Oct 20 '18 at 05:31
  • [How to Delete a File that Contains the "CON" Substring?](https://superuser.com/q/1275452/241386), [How do I remove a file named "NUL" on Windows?](https://superuser.com/q/282194/241386), [Can't delete a folder win 10](https://superuser.com/q/1069857/241386) – phuclv Oct 20 '18 at 05:45

1 Answers1

8

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

Kamil Maciorowski
  • 69,815
  • 22
  • 136
  • 202
dave
  • 116
  • 3