Solved

can't delete a file

Posted on 2008-10-08
19
955 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
ID: 22672707
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
ID: 22672726
it looks like corrputed
0
 
LVL 1

Expert Comment

by:JNRCS
ID: 22672746
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
ID: 22672750
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
ID: 22672769
0
 

Expert Comment

by:ctprof
ID: 22672851
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
ID: 22673204
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
ID: 22673238
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
ID: 22673287
the file is not in use.  There is no Security tab when checking properties.
0
NAS Cloud Backup Strategies

This article explains backup scenarios when using network storage. We review the so-called “3-2-1 strategy” and summarize the methods you can use to send NAS data to the cloud

 

Expert Comment

by:ctprof
ID: 22673341
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
ID: 22673440
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
ID: 22673495
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
ID: 22673620
try this.. in that same directory.. type attrib -s -h *.*
0
 
LVL 47

Expert Comment

by:rpggamergirl
ID: 22673675
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
ID: 22673753
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
ID: 22674590
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
ID: 22674988
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
ID: 22679336
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
ID: 31504405
Connecting from a linux machine to it as a Windows share was the only way I was able to delete it.
0

Featured Post

NAS Cloud Backup Strategies

This article explains backup scenarios when using network storage. We review the so-called “3-2-1 strategy” and summarize the methods you can use to send NAS data to the cloud

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Learn about cloud computing and its benefits for small business owners.
ADCs have gained traction within the last decade, largely due to increased demand for legacy load balancing appliances to handle more advanced application delivery requirements and improve application performance.
This video demonstrates how to create an example email signature rule for a department in a company using CodeTwo Exchange Rules. The signature will be inserted beneath users' latest emails in conversations and will be displayed in users' Sent Items…
A short film showing how OnPage and Connectwise integration works.

914 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

17 Experts available now in Live!

Get 1:1 Help Now