Who has files open on the network

The WhoHasFileOpen utility displays the list of users who have specific file(s) open on network. Works on Windows NT Platform (Windows NT 4.0, Windows 2000, etc). This code detects only the files opened using a net shared path. It does not return the files opened by a user on the local computer using a local path.

The code is based on Ramon F. Jaquez's UT FAQ #7896 Who opened what files on the network? (modified to use only VFP code).

Thanks Kevin Delaney for code cleanup which made possible to post it here for download .

The code uses Windows API support class which is included in the download WhoHasFileOpen.zip as well.

A user running this program must be a member of the Administrators or Account Operators local group on the file server where files are located.

This is sample code. Add error handling and adjust to your requirements as necessary.



Examples

* Mapped drive, specific file 'Sometable.dbf'
WhoHasFileOpen("X:\Somefolder\SumSubfolder\Sometable.dbf")
 
* Mapped drive, all extensions for specific file name 'Sometable'
WhoHasFileOpen("X:\Somefolder\SomeSubfolder\Sometable")
 
* UNC path, specific file 'Sometable.dbf'
WhoHasFileOpen("\\SomeServer\SomeShare\Somefolder\SomemSubfolder\Sometable.dbf")
Your rating: None Average: 5 (2 votes)

Thank you! It's what I need.

Thank you!
It's what I need.

Error 5

Hello,

Pls see the line with the _msgbox(...,64, Unable to continue), there seems to be too many parameters

I changed it to messagebox(), but always get error 5 from netfileenum (admin, file exists on a netshare, a dbf opened by me)

What am I doing wrong ?

BTW : The parameters in the debugger all have one space too much at the end, eg servername "server " while its "server"

Thanks and best regards
tom

Error 5 - Access is denied.

Hi Tom,

The Error 5 is 'Access is denied - The user does not have access to the requested information'. Something is not right with your permissions.

If there was a space at the end of server name, you would get error 123 not 5.

I fixed _msgbox problem an uploaded new version. Thanks.

Error5

Hi
I downloaded the file NOW and I get messagebox 'netsharegetinfoerror acceses ... server(myserver name) share..'.
I get the message even I open this table from vfp and I try 'WhoHasFileOpen' AS FOLLOWING:

 
use q:\data\dorusers.dbf shared
*c:\aaa\=WhoHasFileOpen prg files PATH
cd c:\aaa
set path to c:\aaa
whohasfileopen("Q:\DATA\DORUSERS.dbf")

Thanks

The user running this program must have sufficient rights

The user running this program must be a member of the Administrators or Account Operators local group on the server.

Can I code it?

I have access the table by windows explorer ,by unc and by IP address, in addition I have the server username&password.
Can I access by code or by RunAS from my local?
Thanks

Permisions, permisions, permissions ...

The program does not access the file (table) but queries the server about open files. That's why it requires the user to be a member of the Administrators or Account Operators local group on the server. It should work if you use RunAS with login that is a member of such group.

Good New for my

It is exactly function need, for years, but new future version is view two type data in cursor table or return only the number user and / or the user in array result. i work for this.
Muchas Gracias y disculpe mi ingles. (very tank and sorry for my poor inglish)

Thanks for WhoHasFileOpen

I have been looking into how to accomplish - you have a very elegant and useful solution.

Thank you very much for both your work and that you have decided to share your efforts.