Determining of a drive has files open on it

Recommended Posts

Zaxon 0

Zaxon 0

We you go to close virtual/net drives, you sometimes get a message saying that there a files still open on the drive. Is there anyway in windows to determine whether a given drive has files open on it, or still is actively using the drive in some way? I want my scripts to tap into this.

Share this post

Link to post

Share on other sites

flyingboz 2

flyingboz 2

We you go to close virtual/net drives, you sometimes get a message saying that there a files still open on the drive. Is there anyway in windows to determine whether a given drive has files open on it, or still is actively using the drive in some way? I want my scripts to tap into this.

Look into handle.exe from sysinternals ...

One of the reasons for this behavioris cmd windows left open w/ the current directory located on the drive you wish to disconnect, tho -- no file open, but the behavior will occur - you can use the Process functions and EnvGet to detect / rectify that cause.

Reading the help file before you post... Not only will it make you look smarter, it will make you smarter.

Share this post

Link to post

Share on other sites

Zaxon 0

Zaxon 0

well if your virtual drives all have a number after the drive letter but before the \, you could just:

If IsNumber(StringMid($value,3,1) Then;if this evaluates to true, then it's on a virtual drive.

right?

Riiight, but then there's this:

meaning that I've got to GUESS what c:3 means drive wise. Now if you close the virtual drive and reopen it, it becomes c:4\ - the forth drive open. So the numbers change for the same drive.

...which means that the number changes every time. And if you have, say 5 virtual drives open, there's no way of telling, say, what drive #7 is. It isn't linked to any fixed drive letter. Is c:7\ v:? Is it x:? Who knows! Handle.exe certainly doesn't tell you.
Edited January 18, 2006 by Zaxon

Share this post

Link to post

Share on other sites

seandisanti 3

seandisanti 3

...which means that the number changes every time. And if you have, say 5 virtual drives open, there's no way of telling, say, what drive #7 is. It isn't linked to any fixed drive letter. Is c:7\ v:? Is it x:? Who knows! Handle.exe certainly doesn't tell you.

ah, i was thinking that it had a drive letter (being the virtual drive) and a number...