Fixed Cannot use extended path to delete invalid file

May 30, 2008
80
0
Gerakas, Greece
I have a file on my desktop named "AUX.TXT". According to the MSDN documentation, I should be able to delete that file with the following command:

DEL \\?\C:\Users\GSchizas\Desktop\AUX.TXT

Indeed, that's what happens with Windows Command Processor (cmd.exe).

C:\Users\GSchizas\Desktop>del \\?\C:\Users\GSchizas\Desktop\AUX.TXT

(no output, it's cmd.exe we're talking about)

This also works (undocumented behavior maybe? \\.\ is supposed to be used to directly access devices)

C:\Users\GSchizas\Desktop>del \\.\C:\Users\GSchizas\Desktop\AUX.TXT

In Take Command Console 17, the following works:

C:\Users\GSchizas\Desktop>del \\.\C:\Users\GSchizas\Desktop\AUX.TXT
Deleting \\.\C:\Users\GSchizas\Desktop\AUX.TXT
1 file deleted


Although the documented behavior doesn't:

C:\Users\GSchizas\Desktop>del \\?\C:\Users\GSchizas\Desktop\AUX.TXT
TCC: (Sys) The system cannot find the file specified.
"C:\Users\GSchizas\Desktop\AUX.TXT"
0 files deleted


In Take Command Console 18, both behaviors fail, the documented one:

C:\Users\GSchizas\Desktop>del \\?\C:\Users\GSchizas\Desktop\AUX.TXT
TCC: (Sys) The system cannot find the file specified.
"C:\Users\GSchizas\Desktop\AUX.TXT"
0 files deleted


And the undocumented one (it fails more spectacularly, but it's probably a more consistent fail):

C:\Users\GSchizas\Desktop>del \\.\C:\Users\GSchizas\Desktop\AUX.TXT
TCC: (Sys) The system cannot find the file specified.
"C:\C"
0 files deleted


I can delete the file by using cmd /c del %@quote[\\?\%@full[AUX.TXT]], but TCC should not have to call cmd.exe to perform something as essential as resolving a path.

(This doesn't only apply to invalid filenames, it also applies to very long filenames, filenames with control characters in them etc., filenames written by bad-behaving applications etc.)
 
The \\.\\xxx syntax is wrong (in CMD or TCC) - it means to use the device namespace. (There is a long-standing bug in Windows where this *may* work, but it's still wrong and should be avoided for files.)

I cannot create an "AUX.TXT" file to test -- how did you generate it?
 
I know the \\.\xxx usage it's wrong. It's supposed to only be used to open \\.\C: or \\.\PhysicalDrive1 or stuff like that. I'm not expecting it to work in any TCC, it's just that since the proper \\?\ format didn't work, \\.\ was a good replacement.

Anyway, to make an invalid AUX.TXT on your desktop, just type this:

cmd /c copy nul: \\?\%USERPROFILE%\Desktop\AUX.TXT

You won't be able to delete it, rename it, or do anything with it with the standard shell (so you need to delete it with the command I have in my previous comment).
 

Similar threads

C
Replies
7
Views
3K
Support
CSGalloway@nc.rr.com
C