Solved

can't delete a file

Posted on 2008-10-08
19
942 Views
Last Modified: 2013-12-04
I restored thousands of files from ntbackup to a folder c:\restore, only to decide I needed later to delete this folder.  One file kept me from doing so.  It's attributes are HSA, it's 0 bytes.  If I attempt to delete in Windows Explorer I get:

"Error deleting File or Folder"
Cannot delete file: cannot read from the source file or disk.

I was able to take ownership with other files and delete.  I ended up finding the troubling file, selecting it, inverting my selection and deleted everything else no problem.  It's not causing a big problem for me, but I'd like to understand what's going on.

I can see the file.  I unhid System and Hidden files.  I ran a CHKDSK on the drive which found no problems. CA8HMJKT. is the filename.
0
Comment
Question by:pcrequest
  • 8
  • 3
  • 3
  • +5
19 Comments
 
LVL 3

Expert Comment

by:sonic4269
Comment Utility
try Checking  Effective Permissions.   Right click - properties - Security tab.  Click Advanced - Effective Permissions.  Type in the username you are logged in under. and make sure you have the "delete" permission for the file.

IF you do, and still can't delete it try doing it from a command prompt.

Start - Run then type CMD and hit OK

at the dos box type

cd C:\restore  (or whatever path the file is located in)
del *.*
0
 
LVL 18

Expert Comment

by:sk_raja_raja
Comment Utility
it looks like corrputed
0
 
LVL 1

Expert Comment

by:JNRCS
Comment Utility
Try:

Right click file and select Open With.
Select notepad.
It should give you an error like "This file does not exist, would you like to create a new one?"
Do so.
Write miscellaneous data into it and save.
Delete the file.

Does the file happen to end in a "." ?
0
 
LVL 18

Expert Comment

by:sk_raja_raja
Comment Utility
1.did you try to delete them in sage mode?
2.Open a Command Prompt window and leave it open. Close all open programs. Click Start, Run and enter TASKMGR.EXE Go to the Processes tab and End Process on Explorer.exe. Leave Task Manager open. Go back to the Command Prompt window and change to the directory the undeletable file is located in. At the command prompt type DEL where is the file you wish to delete. Go back to Task Manager, click File, New Task and enter EXPLORER.EXE to restart the GUI shell. Close Task Manager.

Can't delete file or folder:
  http://support.microsoft.com/?kbid=320081
  http://www.theeldergeek.com/delete_undeletable_file.htm

3.deleting with wild cards at a DOS prompt can help, or if possible deleteing all files in that folder.  Renaming file to something very short and then deleting might fix the problem you're experiencing.  If the file is in use I might recommend downloading Process Explorer from http://www.sysinternals.com/  You can search for an open file and what process it belongs to.
0
 
LVL 18

Expert Comment

by:sk_raja_raja
Comment Utility
0
 

Expert Comment

by:ctprof
Comment Utility
Go into a command prompt and do the following...
cd \restore
attrib -s -h CA8HMJKT
del CA8*.*
If the file still does not delete, go into safe mode with command prompt and try the del command from that directory.
0
 
LVL 1

Author Comment

by:pcrequest
Comment Utility
JNRCS

Yes it ends in a dot.  I do as you say with notepad, but a new file is created without ending in dot.  This doens't overwrite the original.
0
 
LVL 1

Author Comment

by:pcrequest
Comment Utility
If I do a dir at the cmd prompt, it lists 0 files in the directory, therefore del, attrib don't work.

I ran a Process Monitor trace and saw results like

NAME NOT FOUND
NO SUCH FILE
0
 
LVL 1

Author Comment

by:pcrequest
Comment Utility
the file is not in use.  There is no Security tab when checking properties.
0
How to improve team productivity

Quip adds documents, spreadsheets, and tasklists to your Slack experience
- Elevate ideas to Quip docs
- Share Quip docs in Slack
- Get notified of changes to your docs
- Available on iOS/Android/Desktop/Web
- Online/Offline

 

Expert Comment

by:ctprof
Comment Utility
dir is not going to work because on the file is the attribute H.  If you go to the command prompt and change to that directory and just type attrib and hit enter it should list the file with the hidden and system attribute on it.  Then you will have the complete file name.  Then you do as stated in previous post..
attrib -s -h filename    then hit enter.  at this point you should be able to do a dir, see the file and delete the file.
0
 
LVL 1

Author Comment

by:pcrequest
Comment Utility
I tried some special sytax for files with invalid names:

C:\restore>del "\\?\c:\old restore\CA8HMJKT."
Could Not Find \\?\c:\old restore\CA8HMJKT.

http://support.microsoft.com/default.aspx?scid=kb;en-us;320081  (see cause 6). Interesting article.

Still didn't work.  
0
 
LVL 1

Author Comment

by:pcrequest
Comment Utility
ctprof,

OK, so dir doesn't list it, but attrib did like you last said, however check out the last line of this post.


C:\old restore>attrib
A  SH      C:\old restore\CA8HMJKT.

C:\old restore>dir
 Volume in drive C has no label.
 Volume Serial Number is redacted

 Directory of C:\old restore

10/08/2008  04:00 PM    <DIR>          .
10/08/2008  04:00 PM    <DIR>          ..
               0 File(s)              0 bytes
               2 Dir(s)  50,591,645,696 bytes free

C:\old restore>attrib -s -h CA8HMJKT.
File not found - CA8HMJKT.
0
 

Expert Comment

by:ctprof
Comment Utility
try this.. in that same directory.. type attrib -s -h *.*
0
 
LVL 47

Expert Comment

by:rpggamergirl
Comment Utility
Have you tried Unlocker? it's a great program for files/folders that are hard to delete.
http://ccollomb.free.fr/unlocker/

Just rightclick on the file and click "Unlock All" and delete.
 http://ccollomb.free.fr/unlocker/unlocker1.8.7.exe
0
 
LVL 1

Author Comment

by:pcrequest
Comment Utility
Tried the crazy subinacl but didn't work:

C:\Program Files\Windows Resource Kits\Tools>subinacl /onlyfile "\\?\C:\oldresto
re\CA8HMJKT." /setowner=administrator /grant=administrator=F
\\?\C:\oldrestore\CA8HMJKT. : dc\administrator is the new owner
\\?\C:\oldrestore\CA8HMJKT. : new ace for dc\administrator
\\?\C:\oldrestore\CA8HMJKT. : 2 change(s)


Elapsed Time: 00 00:00:00
Done:        1, Modified        1, Failed        0, Syntax errors        0
Last Done  : \\?\C:\oldrestore\CA8HMJKT.

C:\Program Files\Windows Resource Kits\Tools>cd c:\oldrestore\

C:\oldrestore>attrib
A  SH      C:\oldrestore\CA8HMJKT.

C:\oldrestore>dir
 Volume in drive C has no label.
 Volume Serial Number is 5092-9BCA

 Directory of C:\oldrestore

10/08/2008  04:00 PM    <DIR>          .
10/08/2008  04:00 PM    <DIR>          ..
               0 File(s)              0 bytes
               2 Dir(s)  50,590,519,296 bytes free

C:\oldrestore>del "\\?\C:\oldrestore\CA8HMJKT."
Could Not Find \\?\C:\oldrestore\CA8HMJKT.
0
 
LVL 9

Accepted Solution

by:
chingmd earned 500 total points
Comment Utility
Have you tried tab completion?  Maybe there are some unprintable characters in the name.
What about renaming the file?  Using a command line or in explorer.   (make sure you have show hidden and system files on, and do not hide file extention for know file types selected.)  

Another way that I've been able to do this is to share the folder.   Then from a linux box, connect to the share and delete from the command line there.

what about a wild card match up?  

You might also look at the program processexplorer from sysinternals to see if something is holding that file open.
0
 
LVL 6

Expert Comment

by:llman
Comment Utility
Did you try: del "\\?\C:\oldrestore\CA8HMJKT.*" or del "\\?\C:\oldrestore\CA8HMJKT*"

Does "dir /x" show a different name for the file that can be used?

0
 
LVL 1

Author Comment

by:pcrequest
Comment Utility
llman

I tried the wildcards, but they didn't work

C:\oldrestore>del "\\?\c:\oldrestore\CA8HMJKT.*"
Could Not Find \\?\c:\oldrestore\CA8HMJKT.*

C:\oldrestore>del "\\?\c:\oldrestore\CA8HMJKT*"
Could Not Find \\?\c:\oldrestore\CA8HMJKT*

C:\oldrestore>dir /x
 Volume in drive C has no label.
 Volume Serial Number is 5092-9BCA

 Directory of C:\oldrestore

10/08/2008  04:00 PM    <DIR>                       .
10/08/2008  04:00 PM    <DIR>                       ..
               0 File(s)              0 bytes
               2 Dir(s)  50,590,371,840 bytes free

C:\oldrestore>attrib
A  SH      C:\oldrestore\CA8HMJKT.
0
 
LVL 1

Author Closing Comment

by:pcrequest
Comment Utility
Connecting from a linux machine to it as a Windows share was the only way I was able to delete it.
0

Featured Post

Superior storage. Superior surveillance.

WD Purple drives are built for 24/7, always-on, high-definition security systems. With support for up to 8 hard drives and 32 cameras, WD Purple drives are optimized for surveillance.

Join & Write a Comment

In a recent article here at Experts Exchange (http://www.experts-exchange.com/articles/18880/PaperPort-14-in-Windows-10-A-First-Look.html), I discussed my nine-month sandbox testing of the Windows 10 Technical Preview, specifically with respect to r…
A quick step-by-step overview of installing and configuring Carbonite Server Backup.
This video discusses moving either the default database or any database to a new volume.
This video gives you a great overview about bandwidth monitoring with SNMP and WMI with our network monitoring solution PRTG Network Monitor (https://www.paessler.com/prtg). If you're looking for how to monitor bandwidth using netflow or packet s…

763 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

13 Experts available now in Live!

Get 1:1 Help Now