Unable to Delete Some Files and Directories

Sometimes I’d find files or folders on my hard drive that I could NOT delete.

These are not files locked by some program, or from wrong permissions. They are files and directories with illegal Windows names.

Trying to rename or delete the file / directory would result in a Windows error message stating “Cannot delete file: Cannot read from the source file or disk.”

Here is an example folder that appears to have no file name:

The “dir /x” command at a command prompt reveals a different DOS/8.3 file name.

The command that worked for me:

rmdir \\.\d:\server\ftp\anon\0202~1

This is from Windows Annoyances regarding someone else who had a similar problem.
(The thread is at: http://www.annoyances.org/exec/forum/win2000/r1012635248)


To answer everyones questions here, I have tested and done a great deal of work on
this, since there is NO documentation on the internet, here is how to create and
remove these ‘rogue’ file/directory names!

How people ‘hackers'(no skill involved) create these files.

Due to some GREAT MS file system setup(POSIX), files with names beginning with com, aux, prn, con, nul, cannot be read under a 32-bit OS as they obviously refer to printing and comm devices, therefore the machine gets confused with these names, BUT some programs are not aware of these, such as, FTP, also, this is not checked when using a UNC connection, ie:

Using UNC

mkdir \\targetmachine\c$\com – this will create an undeletable file. In order to
make it worse:
ren \\targetmachine\c$\com1 – undeletable! and, you, as the creator, cannot rename it either! WOW!

Using FTP

log on as anonymous.
mkdir com – as above
ren com com1 – as above!!!

Poor administrator cannot delete this file :(

So, in order to delete, you will have to rename. As some people have said, doing
a dir /x will show you various bits like perhaps 8.3 notation(eg: com1~002), wrong, it DOES NOT WORK! dir /x will give you NOTHING.

so, solution is

a) You have to log onto the affected machine LOCALLY.
b) ren \\.\c:\com1 file
c) rmdir file

DONE!

If this doesn’t work for someone, please let me know!

krod007 AT hushmail D0T com



UPDATE:

There may be files or folders you can’t seem to delete, even when going through all the above steps.
There are programs out there that have been designed to delete files and folders with invalid names.

DelinvFile is one such program.

Some “SecuROM” copy protection crap got on my system, and created files with invalid names that Explorer could not work with or delete. DelinvFile was able to delete those files.

1 thought on “Unable to Delete Some Files and Directories

  1. command didnt work, the folder/file com1
    D:\Web Sites\tctm.org\HomePageArchive\index040129_files\_vti_cnf\com1 will not go away.
    the command issued from the D:\Web Sites\tctm.org\HomePageArchive\index040129_files\_vti_cnf

    ren .com1 file

    incorrect syntax was result

Comments are closed.