Sign in to follow this  
Followers 0
Zaxon

Determining of a drive has files open on it

9 posts in this topic

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



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

Look into handle.exe from sysinternals ...

Perfect! Thanks for that flyingboz.

Now, the only issue I have is maping the results to their proper drive letters. I don't know if its not interpreting the virtual drives properly or what, but it gives me the following.

As an example, open hello.txt on c: and goodbye.txt on v:. From Handle, I get:

blah blah c:\hello.txt

blah blah c:3\goodbye.txt

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.

How do I make sense of this? If I'm trying to determine if there are any handles open on the v: drive, I have no idea what to call it, and it will be given a different number on different occasions.

Share this post


Link to post
Share on other sites

How do I make sense of this? If I'm trying to determine if there are any handles open on the v: drive, I have no idea what to call it, and it will be given a different number on different occasions.

OK. flyingboz may not know the answer to this. I've posted the same question at the official forum for handle.exe, but I'm getting no replies of any sort.

So failing a resolution on this product, I'll open the question back up again and ask if anyone knows of another way of detecting of their are open handles on a given drive?

Share this post


Link to post
Share on other sites

Perfect! Thanks for that flyingboz.

Now, the only issue I have is maping the results to their proper drive letters. I don't know if its not interpreting the virtual drives properly or what, but it gives me the following.

As an example, open hello.txt on c: and goodbye.txt on v:. From Handle, I get:

blah blah c:\hello.txt

blah blah c:3\goodbye.txt

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.

How do I make sense of this? If I'm trying to determine if there are any handles open on the v: drive, I have no idea what to call it, and it will be given a different number on different occasions.

OK. flyingboz may not know the answer to this. I've posted the same question at the official forum for handle.exe, but I'm getting no replies of any sort.

So failing a resolution on this product, I'll open the question back up again and ask if anyone knows of another way of detecting of their are open handles on a given drive?

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?


1100111 00001011101111 00011101101111 00010111100100 00001111110100 00110111110010 00101101111001 0011100i didn't make up this form of encryption, but i like it.credit to the lvl 6 challenge on arcanum.co.nz

Share this post


Link to post
Share on other sites

#6 ·  Posted (edited)

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 by Zaxon

Share this post


Link to post
Share on other sites

Riiight, but then there's this:

...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...

1100111 00001011101111 00011101101111 00010111100100 00001111110100 00110111110010 00101101111001 0011100i didn't make up this form of encryption, but i like it.credit to the lvl 6 challenge on arcanum.co.nz

Share this post


Link to post
Share on other sites

There is a secret arcane Microsoft utility called 'oh.exe' which shows all open file handles on your system and which process has them open. Google around and eventually you'll find it! Good luck!

Share this post


Link to post
Share on other sites

Thanks anyway cameronsdad.

There is a secret arcane Microsoft utility called 'oh.exe' which shows all open file handles on your system and which process has them open. Google around and eventually you'll find it! Good luck!

With a few secret handshakes and wearing an apron while riding a goat, I found oh.exe. Now, it lists every file starting with \ .

So c:\hello.txt and d:\hello.txt are listed as:

blah blah \hello.txt

blah blah \hello.txt

So it doesn't even acknowledge that the files are on different drives

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0