Problem on deleting file

To all:

Im trying to delete a file (it has a normal attribute), and
an error occurred like this:
“ACCESS DENIED. FILE MAY BE IN USE.”
How can I delete this file w/o knowing which application used
this file?

thanks in advance,
-Rick-


Get Your Private, Free E-mail from MSN Hotmail at http://www.hotmail.com.


You are currently subscribed to ntdev as: $subst(‘Recip.EmailAddr’)
To unsubscribe send a blank email to leave-ntdev-$subst(‘Recip.MemberIDChar’)@lists.osr.com

You can’t. The file will be locked by the OS.
You must know what application is using it. If an application thread that is
using the file fails to exit you can go to the task manager and kill the
process.

-----Original Message-----
From: xxxxx@lists.osr.com
[mailto:xxxxx@lists.osr.com]On Behalf Of Ricky Villegas
Sent: Wednesday, February 28, 2001 11:54 AM
To: NT Developers Interest List
Subject: [ntdev] Problem on deleting file

To all:

Im trying to delete a file (it has a normal attribute), and
an error occurred like this:
“ACCESS DENIED. FILE MAY BE IN USE.”
How can I delete this file w/o knowing which application used
this file?

thanks in advance,
-Rick-


Get Your Private, Free E-mail from MSN Hotmail at http://www.hotmail.com.


You are currently subscribed to ntdev as: xxxxx@powernetsys.com
To unsubscribe send a blank email to leave-ntdev-$subst(‘Recip.MemberIDChar’)@lists.osr.com


You are currently subscribed to ntdev as: $subst(‘Recip.EmailAddr’)
To unsubscribe send a blank email to leave-ntdev-$subst(‘Recip.MemberIDChar’)@lists.osr.com

Hi Rick,

I think some application might be using the file, so you are getting that
error. Close all the opened application and then delete that file.

Thanks!
Rgds,
Sunil

Ricky Villegas wrote:

To all:

Im trying to delete a file (it has a normal attribute), and
an error occurred like this:
“ACCESS DENIED. FILE MAY BE IN USE.”
How can I delete this file w/o knowing which application used
this file?

thanks in advance,
-Rick-


Get Your Private, Free E-mail from MSN Hotmail at http://www.hotmail.com.


You are currently subscribed to ntdev as: xxxxx@teil.soft.net
To unsubscribe send a blank email to leave-ntdev-$subst(‘Recip.MemberIDChar’)@lists.osr.com


You are currently subscribed to ntdev as: $subst(‘Recip.EmailAddr’)
To unsubscribe send a blank email to leave-ntdev-$subst(‘Recip.MemberIDChar’)@lists.osr.com

This just begs the question… how does one find out which application is
holding a file open. Sometimes it’s obvious (*.doc is probably MSWord). But
sometimes it’s not (msvc42.dll). There’s got to be an API, right?

ERX

-----Original Message-----
From: Stas Desy [mailto:xxxxx@powernetsys.com]
Sent: Wednesday, February 28, 2001 7:32 AM
To: NT Developers Interest List
Subject: [ntdev] RE: Problem on deleting file

You can’t. The file will be locked by the OS.
You must know what application is using it. If an application
thread that is
using the file fails to exit you can go to the task manager
and kill the
process.

-----Original Message-----
From: xxxxx@lists.osr.com
[mailto:xxxxx@lists.osr.com]On Behalf Of Ricky Villegas
Sent: Wednesday, February 28, 2001 11:54 AM
To: NT Developers Interest List
Subject: [ntdev] Problem on deleting file

To all:

Im trying to delete a file (it has a normal attribute), and
an error occurred like this:
“ACCESS DENIED. FILE MAY BE IN USE.”
How can I delete this file w/o knowing which application used
this file?

thanks in advance,
-Rick-



Get Your Private, Free E-mail from MSN Hotmail at
http://www.hotmail.com.


You are currently subscribed to ntdev as: xxxxx@powernetsys.com
To unsubscribe send a blank email to leave-ntdev-$subst(‘Recip.MemberIDChar’)@lists.osr.com


You are currently subscribed to ntdev as: xxxxx@mediasite.com
To unsubscribe send a blank email to leave-ntdev-$subst(‘Recip.MemberIDChar’)@lists.osr.com


You are currently subscribed to ntdev as: $subst(‘Recip.EmailAddr’)
To unsubscribe send a blank email to leave-ntdev-$subst(‘Recip.MemberIDChar’)@lists.osr.com

> -----Original Message-----

From: Steadle, Eric [mailto:xxxxx@mediasite.com]
This just begs the question… how does one find out which
application is
holding a file open. Sometimes it’s obvious (*.doc is
probably MSWord). But
sometimes it’s not (msvc42.dll). There’s got to be an API, right?

There are a number of utilities that will list open libraries and all of the
processes that are holding them open. The freeware (shareware???) called
“ModuleList” is one of them. It also shows the full path of the holding
module which can be important if an app is stored in multiple palces on a
system.

Craig Denbrook
Senior Principal Investigator
Sparta, Inc


You are currently subscribed to ntdev as: $subst(‘Recip.EmailAddr’)
To unsubscribe send a blank email to leave-ntdev-$subst(‘Recip.MemberIDChar’)@lists.osr.com

Here are a couple of useful commad-line utilities:
http://www.sysinternals.com/ntw2k/freeware/listdlls.shtml
http://www.sysinternals.com/ntw2k/freeware/handle.shtml

For a GUI one that combines both:
http://www.sysinternals.com/ntw2k/freeware/handleex.shtml

  • Danilo

-----Original Message-----
From: xxxxx@lists.osr.com
[mailto:xxxxx@lists.osr.com]On Behalf Of Steadle, Eric
Sent: Thursday, March 01, 2001 10:39 AM
To: NT Developers Interest List
Subject: [ntdev] RE: Problem on deleting file

This just begs the question… how does one find out which application is
holding a file open. Sometimes it’s obvious (*.doc is probably MSWord). But
sometimes it’s not (msvc42.dll). There’s got to be an API, right?

ERX

-----Original Message-----
From: Stas Desy [mailto:xxxxx@powernetsys.com]
Sent: Wednesday, February 28, 2001 7:32 AM
To: NT Developers Interest List
Subject: [ntdev] RE: Problem on deleting file

You can’t. The file will be locked by the OS.
You must know what application is using it. If an application
thread that is
using the file fails to exit you can go to the task manager
and kill the
process.

-----Original Message-----
From: xxxxx@lists.osr.com
[mailto:xxxxx@lists.osr.com]On Behalf Of Ricky Villegas
Sent: Wednesday, February 28, 2001 11:54 AM
To: NT Developers Interest List
Subject: [ntdev] Problem on deleting file

To all:

Im trying to delete a file (it has a normal attribute), and
an error occurred like this:
“ACCESS DENIED. FILE MAY BE IN USE.”
How can I delete this file w/o knowing which application used
this file?

thanks in advance,
-Rick-


You are currently subscribed to ntdev as: $subst(‘Recip.EmailAddr’)
To unsubscribe send a blank email to leave-ntdev-$subst(‘Recip.MemberIDChar’)@lists.osr.com

I must apologize… I used a bad example when I picked a DLL file name.

I suspect most of us are familiar with the “sysinternals” utilities. And
while they are quite useful for finding out which application is currently
holding onto a DLL or program file, there are situations where a general
purpose “Who’s got this file open” utility would be better – a utility that
would tell you which program has “readme.txt” open.

During my normal everyday usage of Windows I delete directories or lists of
files. Sometimes Explorer tells me that it can’t comply because one or more
of the files or directories I’m deleting are currently being used. (Let’s
ignore the brain-dead behavior Explorer itself exhibits if IT happens to be
the application that currently has a directory open.) Sometimes this file is
a DLL, but sometimes, it’s not. I can use a sysinternals utility if it’s a
DLL, but if it’s not… well.

The best behavior I could expect from a file utility would be an error
message that tells me WHICH file or directory can’t be deleted, and WHICH
application or process is holding that file open so that I could go ahead
and close that application and finish what I was doing. Instead, I play a
game of “guess which application needs this file”. That game is fun for the
first 3 seconds, but quickly becomes tedious as I make my way through Task
Manager’s 100+ item running process list.

My real question is, somewhere in the file system, the network apis, the
system objects table, or the kernel, somebody knows who has that file open.
How do I get to that information so that I can write a replacement for
Explorer that does the proverbial “right thing”?

ERX

-----Original Message-----
From: Danilo Almeida [mailto:xxxxx@MIT.EDU]
Sent: Thursday, March 01, 2001 11:27 AM
To: NT Developers Interest List
Subject: [ntdev] RE: Problem on deleting file

Here are a couple of useful commad-line utilities:
http://www.sysinternals.com/ntw2k/freeware/listdlls.shtml
http://www.sysinternals.com/ntw2k/freeware/handle.shtml

For a GUI one that combines both:
http://www.sysinternals.com/ntw2k/freeware/handleex.shtml

  • Danilo

-----Original Message-----
From: xxxxx@lists.osr.com
[mailto:xxxxx@lists.osr.com]On Behalf Of Steadle, Eric
Sent: Thursday, March 01, 2001 10:39 AM
To: NT Developers Interest List
Subject: [ntdev] RE: Problem on deleting file

This just begs the question… how does one find out which
application is
holding a file open. Sometimes it’s obvious (*.doc is
probably MSWord). But
sometimes it’s not (msvc42.dll). There’s got to be an API, right?

ERX

> -----Original Message-----
> From: Stas Desy [mailto:xxxxx@powernetsys.com]
> Sent: Wednesday, February 28, 2001 7:32 AM
> To: NT Developers Interest List
> Subject: [ntdev] RE: Problem on deleting file
>
>
> You can’t. The file will be locked by the OS.
> You must know what application is using it. If an application
> thread that is
> using the file fails to exit you can go to the task manager
> and kill the
> process.
>
>
> -----Original Message-----
> From: xxxxx@lists.osr.com
> [mailto:xxxxx@lists.osr.com]On Behalf Of Ricky Villegas
> Sent: Wednesday, February 28, 2001 11:54 AM
> To: NT Developers Interest List
> Subject: [ntdev] Problem on deleting file
>
>
> To all:
>
> Im trying to delete a file (it has a normal attribute), and
> an error occurred like this:
> “ACCESS DENIED. FILE MAY BE IN USE.”
> How can I delete this file w/o knowing which application used
> this file?
>
> thanks in advance,
> -Rick-


You are currently subscribed to ntdev as: xxxxx@mediasite.com
To unsubscribe send a blank email to leave-ntdev-$subst(‘Recip.MemberIDChar’)@lists.osr.com


You are currently subscribed to ntdev as: $subst(‘Recip.EmailAddr’)
To unsubscribe send a blank email to leave-ntdev-$subst(‘Recip.MemberIDChar’)@lists.osr.com

Hello Eric,

The programtical solution to this problem would probably mean looking
for open handles. The ZwQuerySystemInformation api using the
SystemHandleInformation will allow you to enumerate handles and will
give you the PID of the owning process. You will find it exported from
ntdll.dll.

Regards,
Anders Fogh

P.s. If you do write such a program - please send me a copy… you’re
not the only one with such problems. :wink:

Thursday, March 01, 2001, 8:57:25 AM, you wrote:

SE> I must apologize… I used a bad example when I picked a DLL file name.

SE> I suspect most of us are familiar with the “sysinternals” utilities. And
SE> while they are quite useful for finding out which application is currently
SE> holding onto a DLL or program file, there are situations where a general
SE> purpose “Who’s got this file open” utility would be better – a utility that
SE> would tell you which program has “readme.txt” open.

SE> During my normal everyday usage of Windows I delete directories or lists of
SE> files. Sometimes Explorer tells me that it can’t comply because one or more
SE> of the files or directories I’m deleting are currently being used. (Let’s
SE> ignore the brain-dead behavior Explorer itself exhibits if IT happens to be
SE> the application that currently has a directory open.) Sometimes this file is
SE> a DLL, but sometimes, it’s not. I can use a sysinternals utility if it’s a
SE> DLL, but if it’s not… well.

SE> The best behavior I could expect from a file utility would be an error
SE> message that tells me WHICH file or directory can’t be deleted, and WHICH
SE> application or process is holding that file open so that I could go ahead
SE> and close that application and finish what I was doing. Instead, I play a
SE> game of “guess which application needs this file”. That game is fun for the
SE> first 3 seconds, but quickly becomes tedious as I make my way through Task
SE> Manager’s 100+ item running process list.

SE> My real question is, somewhere in the file system, the network apis, the
SE> system objects table, or the kernel, somebody knows who has that file open.
SE> How do I get to that information so that I can write a replacement for
SE> Explorer that does the proverbial “right thing”?

SE> ERX

> -----Original Message-----
> From: Danilo Almeida [mailto:xxxxx@MIT.EDU]
> Sent: Thursday, March 01, 2001 11:27 AM
> To: NT Developers Interest List
> Subject: [ntdev] RE: Problem on deleting file
>
>
> Here are a couple of useful commad-line utilities:
> http://www.sysinternals.com/ntw2k/freeware/listdlls.shtml
> http://www.sysinternals.com/ntw2k/freeware/handle.shtml
>
> For a GUI one that combines both:
> http://www.sysinternals.com/ntw2k/freeware/handleex.shtml
>
> - Danilo
>
> -----Original Message-----
> From: xxxxx@lists.osr.com
> [mailto:xxxxx@lists.osr.com]On Behalf Of Steadle, Eric
> Sent: Thursday, March 01, 2001 10:39 AM
> To: NT Developers Interest List
> Subject: [ntdev] RE: Problem on deleting file
>
>
> This just begs the question… how does one find out which
> application is
> holding a file open. Sometimes it’s obvious (*.doc is
> probably MSWord). But
> sometimes it’s not (msvc42.dll). There’s got to be an API, right?
>
> ERX
>
>
>
> > -----Original Message-----
> > From: Stas Desy [mailto:xxxxx@powernetsys.com]
> > Sent: Wednesday, February 28, 2001 7:32 AM
> > To: NT Developers Interest List
> > Subject: [ntdev] RE: Problem on deleting file
> >
> >
> > You can’t. The file will be locked by the OS.
> > You must know what application is using it. If an application
> > thread that is
> > using the file fails to exit you can go to the task manager
> > and kill the
> > process.
> >
> >
> > -----Original Message-----
> > From: xxxxx@lists.osr.com
> > [mailto:xxxxx@lists.osr.com]On Behalf Of Ricky Villegas
> > Sent: Wednesday, February 28, 2001 11:54 AM
> > To: NT Developers Interest List
> > Subject: [ntdev] Problem on deleting file
> >
> >
> > To all:
> >
> > Im trying to delete a file (it has a normal attribute), and
> > an error occurred like this:
> > “ACCESS DENIED. FILE MAY BE IN USE.”
> > How can I delete this file w/o knowing which application used
> > this file?
> >
> > thanks in advance,
> > -Rick-
>
>
> —
> You are currently subscribed to ntdev as: xxxxx@mediasite.com
> To unsubscribe send a blank email to leave-ntdev-$subst(‘Recip.MemberIDChar’)@lists.osr.com
>

SE> —
SE> You are currently subscribed to ntdev as: xxxxx@flaffer.com
SE> To unsubscribe send a blank email to leave-ntdev-$subst(‘Recip.MemberIDChar’)@lists.osr.com


Best regards,
Anders mailto:xxxxx@flaffer.com


You are currently subscribed to ntdev as: $subst(‘Recip.EmailAddr’)
To unsubscribe send a blank email to leave-ntdev-$subst(‘Recip.MemberIDChar’)@lists.osr.com

Bingo… that’s helpful. Thanks!

ERX

-----Original Message-----
From: Anders Fogh [mailto:xxxxx@flaffer.com]
Sent: Friday, March 02, 2001 12:26 AM
To: NT Developers Interest List
Subject: [ntdev] RE: Problem on deleting file

Hello Eric,

The programtical solution to this problem would probably mean looking
for open handles. The ZwQuerySystemInformation api using the
SystemHandleInformation will allow you to enumerate handles and will
give you the PID of the owning process. You will find it exported from
ntdll.dll.

Regards,
Anders Fogh

P.s. If you do write such a program - please send me a copy… you’re
not the only one with such problems. :wink:

Thursday, March 01, 2001, 8:57:25 AM, you wrote:

SE> I must apologize… I used a bad example when I picked a
DLL file name.

SE> I suspect most of us are familiar with the “sysinternals”
utilities. And
SE> while they are quite useful for finding out which
application is currently
SE> holding onto a DLL or program file, there are situations
where a general
SE> purpose “Who’s got this file open” utility would be
better – a utility that
SE> would tell you which program has “readme.txt” open.

SE> During my normal everyday usage of Windows I delete
directories or lists of
SE> files. Sometimes Explorer tells me that it can’t comply
because one or more
SE> of the files or directories I’m deleting are currently
being used. (Let’s
SE> ignore the brain-dead behavior Explorer itself exhibits
if IT happens to be
SE> the application that currently has a directory open.)
Sometimes this file is
SE> a DLL, but sometimes, it’s not. I can use a sysinternals
utility if it’s a
SE> DLL, but if it’s not… well.

SE> The best behavior I could expect from a file utility
would be an error
SE> message that tells me WHICH file or directory can’t be
deleted, and WHICH
SE> application or process is holding that file open so that
I could go ahead
SE> and close that application and finish what I was doing.
Instead, I play a
SE> game of “guess which application needs this file”. That
game is fun for the
SE> first 3 seconds, but quickly becomes tedious as I make my
way through Task
SE> Manager’s 100+ item running process list.

SE> My real question is, somewhere in the file system, the
network apis, the
SE> system objects table, or the kernel, somebody knows who
has that file open.
SE> How do I get to that information so that I can write a
replacement for
SE> Explorer that does the proverbial “right thing”?

SE> ERX

>> -----Original Message-----
>> From: Danilo Almeida [mailto:xxxxx@MIT.EDU]
>> Sent: Thursday, March 01, 2001 11:27 AM
>> To: NT Developers Interest List
>> Subject: [ntdev] RE: Problem on deleting file
>>
>>
>> Here are a couple of useful commad-line utilities:
>> http://www.sysinternals.com/ntw2k/freeware/listdlls.shtml
>> http://www.sysinternals.com/ntw2k/freeware/handle.shtml
>>
>> For a GUI one that combines both:
>> http://www.sysinternals.com/ntw2k/freeware/handleex.shtml
>>
>> - Danilo
>>
>> -----Original Message-----
>> From: xxxxx@lists.osr.com
>> [mailto:xxxxx@lists.osr.com]On Behalf Of Steadle, Eric
>> Sent: Thursday, March 01, 2001 10:39 AM
>> To: NT Developers Interest List
>> Subject: [ntdev] RE: Problem on deleting file
>>
>>
>> This just begs the question… how does one find out which
>> application is
>> holding a file open. Sometimes it’s obvious (*.doc is
>> probably MSWord). But
>> sometimes it’s not (msvc42.dll). There’s got to be an API, right?
>>
>> ERX
>>
>>
>>
>> > -----Original Message-----
>> > From: Stas Desy [mailto:xxxxx@powernetsys.com]
>> > Sent: Wednesday, February 28, 2001 7:32 AM
>> > To: NT Developers Interest List
>> > Subject: [ntdev] RE: Problem on deleting file
>> >
>> >
>> > You can’t. The file will be locked by the OS.
>> > You must know what application is using it. If an application
>> > thread that is
>> > using the file fails to exit you can go to the task manager
>> > and kill the
>> > process.
>> >
>> >
>> > -----Original Message-----
>> > From: xxxxx@lists.osr.com
>> > [mailto:xxxxx@lists.osr.com]On Behalf Of
Ricky Villegas
>> > Sent: Wednesday, February 28, 2001 11:54 AM
>> > To: NT Developers Interest List
>> > Subject: [ntdev] Problem on deleting file
>> >
>> >
>> > To all:
>> >
>> > Im trying to delete a file (it has a normal attribute), and
>> > an error occurred like this:
>> > “ACCESS DENIED. FILE MAY BE IN USE.”
>> > How can I delete this file w/o knowing which application used
>> > this file?
>> >
>> > thanks in advance,
>> > -Rick-
>>
>>
>> —
>> You are currently subscribed to ntdev as: xxxxx@mediasite.com
>> To unsubscribe send a blank email to
leave-ntdev-$subst(‘Recip.MemberIDChar’)@lists.osr.com
>>

SE> —
SE> You are currently subscribed to ntdev as: xxxxx@flaffer.com
SE> To unsubscribe send a blank email to
leave-ntdev-$subst(‘Recip.MemberIDChar’)@lists.osr.com


Best regards,
Anders mailto:xxxxx@flaffer.com


You are currently subscribed to ntdev as: xxxxx@mediasite.com
To unsubscribe send a blank email to leave-ntdev-$subst(‘Recip.MemberIDChar’)@lists.osr.com


You are currently subscribed to ntdev as: $subst(‘Recip.EmailAddr’)
To unsubscribe send a blank email to leave-ntdev-$subst(‘Recip.MemberIDChar’)@lists.osr.com

Eric,

System Internals NTHandle command line utility is ideal for this purpose.
For example “nthandle readme” command will dump all handles to objects with
names containing “readme” fragment. The line with handle information
contains process name and PID.

Also their HandleEx can display opened handles to any file, not only DLLs.
Just select View | View Handle instead of DLLs.

Best regards,

Michal Vodicka
Veridicom
(RKK - Skytale)
[WWW: http://www.veridicom.com , http://www.skytale.com]


From: Steadle, Eric[SMTP:xxxxx@mediasite.com]
Reply To: NT Developers Interest List
Sent: Thursday, March 01, 2001 5:57 PM
To: NT Developers Interest List
Subject: [ntdev] RE: Problem on deleting file

I must apologize… I used a bad example when I picked a DLL file name.

I suspect most of us are familiar with the “sysinternals” utilities. And
while they are quite useful for finding out which application is currently
holding onto a DLL or program file, there are situations where a general
purpose “Who’s got this file open” utility would be better – a utility
that
would tell you which program has “readme.txt” open.

During my normal everyday usage of Windows I delete directories or lists
of
files. Sometimes Explorer tells me that it can’t comply because one or
more
of the files or directories I’m deleting are currently being used. (Let’s
ignore the brain-dead behavior Explorer itself exhibits if IT happens to
be
the application that currently has a directory open.) Sometimes this file
is
a DLL, but sometimes, it’s not. I can use a sysinternals utility if it’s a
DLL, but if it’s not… well.

The best behavior I could expect from a file utility would be an error
message that tells me WHICH file or directory can’t be deleted, and WHICH
application or process is holding that file open so that I could go ahead
and close that application and finish what I was doing. Instead, I play a
game of “guess which application needs this file”. That game is fun for
the
first 3 seconds, but quickly becomes tedious as I make my way through Task
Manager’s 100+ item running process list.

My real question is, somewhere in the file system, the network apis, the
system objects table, or the kernel, somebody knows who has that file
open.
How do I get to that information so that I can write a replacement for
Explorer that does the proverbial “right thing”?

ERX


You are currently subscribed to ntdev as: $subst(‘Recip.EmailAddr’)
To unsubscribe send a blank email to leave-ntdev-$subst(‘Recip.MemberIDChar’)@lists.osr.com