Deleting undeletable file

HCHTech

Well-Known Member
Reaction score
4,203
Location
Pittsburgh, PA - USA
So, one of my commercial customers has a couple of copiers that scan things to PDF and store them on the network. You can choose the location and the filename during the scan. Simple enough....until one of the idiots there decided today to name a scanned file "Con.pdf". As soon as I read her email I knew this was going to be trouble.

This is an ESXi setup, and the file is in a user directory on the App server's (Server 2012R2) data drive.

If this were a workstation, I would just boot it up to Parted Magic, and delete the file there, but I'm not keen to do this to a server - not to mention the downtime necessary.

I've tried about every command line combination with and without $ prefixes, using \\. prefixes, etc. So far, nothing has worked. I'm thinking this is going to cause problems with our backups at the very least.

Google is not helping. Suggestions, anyone?
 
Last edited:
RDP to the server, crack open an admin command prompt...

Copy everything you can out of the folder with the grumpy file.

Then make a new folder that's empty... robocopy /mir /r:0 /w:0 newfolder oldfolder (You want to mirror an empty folder over the top of the one with the bad file in it)

That should flush the file... then you copy the other stuff back.

Then install an FTP service to interface with the scanner so it stops mucking up your SMB. Or better, scan to email.

I've had to do this a few times in similar circumstances.
 
Left over ancient DOS stuff... wow.

SAFScaper's solution is vastly more elegant than mine, I'm going to have to remember that one. I didn't even know that DOS had an escape sequence for file name parsing.
 
You can choose the location and the filename during the scan.
Is there any way to set a filename template or pad a short name to (e.g.) eight characters? It can only be a matter of time before some wag discovers the other reserved names. Or even populate the destination directory with dummy, hidden files using reserved names, presuming that the scanner can't overwrite an existing filename.
 
Simple enough....until one of the idiots there decided today to name a scanned file "Con.pdf".

I haven't LOL'd like that in a long time. Thank you, I needed that.

I can't say that I've ever encountered this before, and I'm not stupid enough to name anything con, but you might want to try using an alternative file manager. 7zip is the one I usually use.
 
del \\?\C:\folder\con.pdf

This one worked - thanks @SAFCasper . I was on the right track, but was using "\\." instead of "\\?" Did not know about that one - putting it in my evernote for the next time. Thanks!

@Sky-Knight has the right idea of switching this to using FTP instead of using SMB to avoid this nonsense. I'll have to put that on my to-do list. They have 4 devices that can do this scanning, with 30 users or so setup on each device, so I'm not looking forward to those 120 edits to change the methodology - ugh. I'm surprised this hasn't happened before, frankly.
 
Back
Top