deleting files that are in use

Y

yawnmoth

Occasionally, when attempting to delete a file, I'll get the following
error:

Cannot delete filename: Access is denied.

Make sure the disk is not full or write-protected and that the file is
not currently in use.

Since I know the file not to be write-protected and since the disk
isn't full, I think it's safe to assume that the file is currently in
use (or that some application thinks the directory being deleted is its
current directory). However, often times, finding out what this
application is isn't so easy. Especially if you have a lot open.

There wouldn't be an easy way to figure out which application was
responsible for that error, would there be?
 
P

Pez D Spencer

what is the file?

usually the way i would do it would be: terminate the process and then
delete.

i understand that it'd difficult to pinpoint it in task manager
sometimes, hence the first question.
 
Y

yawnmoth

Pez said:
what is the file?

usually the way i would do it would be: terminate the process and then
delete.

i understand that it'd difficult to pinpoint it in task manager
sometimes, hence the first question.
It's actually a directory. I should have stated that...
 
S

Small Potato

There wouldn't be an easy way to figure out which application was
responsible for that error, would there be?

There is a utility called "Unlocker". It serves this purpose.
 
P

Pegasus \(MVP\)

yawnmoth said:
Occasionally, when attempting to delete a file, I'll get the following
error:

Cannot delete filename: Access is denied.

Make sure the disk is not full or write-protected and that the file is
not currently in use.

Since I know the file not to be write-protected and since the disk
isn't full, I think it's safe to assume that the file is currently in
use (or that some application thinks the directory being deleted is its
current directory). However, often times, finding out what this
application is isn't so easy. Especially if you have a lot open.

There wouldn't be an easy way to figure out which application was
responsible for that error, would there be?

Here are two tools that will tell you what application holds
on to a file:
- nthandle.exe from www.SysInternals.com
- oh.exe (Win2000 Resource Kit)
 
P

Pez D Spencer

yawnmoth said:
It's actually a directory. I should have stated that...

without knowing exactly what directory you're talking about -- and at
the risk of sounding like an idiot -- have you tried restarting in safe
mode and then attempting to delete it?
 
G

Guest

I have exactly the same problem. I am administator and aonly user on the
system. Moreover, this files that causes the problem are on a letter of a
DVD-R drive, wich doesn't contain any DVD! I suppose it's something like a
virtual DVD, but anyway it refuses to copy the files on DVD, saying that the
copie doesn't succeed as it is impossible to clear up this virtual file(s)
after the copie (cannot delete etc...).

One of this files is eg ARIEL.TTF. I cannot see hows a TTF-file can give so
much problems.

Another (tempoary) solution should be that somebody tells me how I can
access this DVD-R_drive without the system telling me each that there are
'files waiting to be written'. Each time I do say 'wite to CD', it tells me
that it is impossible, resulting in the famous result above.
 
C

Code Blue

Hmmm, I don't see much harm in killing explorer and restarting it, that
could solve the problem in case of a directory...
 
S

Small Potato

Hmmm, I don't see much harm in killing explorer and restarting it, that
could solve the problem in case of a directory...

There is no harm. Unlocker is simply easier than killing explorer and
restarting it in Task Manager or Process Explorer.

Of course, Unlocker can do more than simply unlocking a file handle.
 
P

Pennywise

|>
|>Code Blue wrote:
|>> yawnmoth,
|>>
|>> this will solve your problem (you can search for the file name and it
|>> will tell you which process/dll is using it, amongst other things).
|>> This utility is like TaskManager on steroids. Enjoy.

|>> http://www.sysinternals.com/Utilities/ProcessExplorer.html
|>According to that tool, explorer.exe is the culprit. Does that mean
|>I'll need to crash explorer (or reboot) just do delete the files?

Couldn't hurt just kill the explorer task in Process explorer, it will
restart. less some of your start up programs.
 
M

mhc

yawnmoth said:
It's actually a directory. I should have stated that...
If you're getting "Access denied" messages, go to the CMD.EXE command
prompt and type: RD "directoryname" /S /Q

and see if the directory can be deleted. Replace directoryname with the
name of your directory, and make sure to use the quotes. Unless this is
a system directory to which you don't have permission to remove, this
above command should work.

If you're getting "Directory is being used by another process" messages,
then you will need to terminate the process which is using the directory
before you can delete it. If Explorer is the process, you can use Task
Manager to terminate Explorer, then run CMD.EXE directly out of Task
Manager, and use the RD command to remove the directory. Once complete,
you can terminate CMD.EXE and re-start Explorer.
 
U

Unk

Occasionally, when attempting to delete a file, I'll get the following
error:

Cannot delete filename: Access is denied.

Make sure the disk is not full or write-protected and that the file is
not currently in use.

Since I know the file not to be write-protected and since the disk
isn't full, I think it's safe to assume that the file is currently in
use (or that some application thinks the directory being deleted is its
current directory). However, often times, finding out what this
application is isn't so easy. Especially if you have a lot open.

There wouldn't be an easy way to figure out which application was
responsible for that error, would there be?

Unlocker - Freeware
http://ccollomb.free.fr/unlocker/
 
C

cquirke (MVP Windows shell/user)

Not that I can think of - when this happens, I close all apps and see
if that helps. If still no joy, and it isn't Windows itself that is
holding the file open, then it may be legitimate "underfootware" such
as drivers or SysTray apps, or malware.

Safe Mode suppresses many of these factors and is the next thing to
try; after that, you'd have to go deeper - avoid running the hard
drive at all (Bart PE CDR boot, or DOS mode if < 137G and FATxx), or
tackling the running tasks by hand (usually a bad idea).

Be careful when deleting files normally in use - you may "break"
something and cause Windows not to boot! So I'd:
- ensure you have a non-HD-based maintenance OS
- if < 137G HD and FATxx file systems, can use DOS mode
- else use Bart PE CDR; do a Google( Bart PE ) for more
- rename away, rather than delete, the suspect files
- do this renaming outside the HD-based OS if possible

The reason for the last is that:
- Windows may track references to file so still in use thereafter
- running malware may actively defend itself, or strike back

If you need to know what is using the file, you can search for
references to it, using the following approaches...
- Regedit search for the name (or use Nirsoft's RegScanner)
- search the file system for files containing the name as text
- inspect the file itself, e.g. to trace its dependencies
....but I'd want to make sure it isn't malware before doing the
above, especially inspecing the file itself.


-------------------- ----- ---- --- -- - - - -
Running Windows-based av to kill active malware is like striking
a match to see if what you are standing in is water or petrol.
 
M

Michael Stevens

yawnmoth said:
Occasionally, when attempting to delete a file, I'll get the following
error:

Cannot delete filename: Access is denied.

Make sure the disk is not full or write-protected and that the file is
not currently in use.

Since I know the file not to be write-protected and since the disk
isn't full, I think it's safe to assume that the file is currently in
use (or that some application thinks the directory being deleted is
its current directory). However, often times, finding out what this
application is isn't so easy. Especially if you have a lot open.

There wouldn't be an easy way to figure out which application was
responsible for that error, would there be?

http://www.dougknox.com/xp/tips/xp_undeletable_file.htm
--
Michael Stevens MS-MVP XP
(e-mail address removed)
http://www.michaelstevenstech.com
For a better newsgroup experience. Setup a newsreader.
http://www.michaelstevenstech.com/outlookexpressnewreader.htm
 
X

xfile

Hi,

It also happens to me once a while.

I notice that several occasions was using Adobe PhotoShop doing some image
editing. Even I closed the file from Photoshop, I couldn't delete it.

The solution for my case is - close Windows Explorer and re-open it.

I have no idea for why would this happen, maybe it's because of "cache" or
something similar stored by Windows or Adobe PhotoShop.

I rarely experienced other similar situations, but if I remembered
correctly, I could usually solve it by closing down everything and then log
off (not reboot) and log back again.

Hope this helps.
 
D

Doug

Yes, kill explorer with task manager then "run "explorer using
task manager. Then you can delete the file. Now wasn't that
easy.

Doug W.

..
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads


Top