Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Which user has a file open? Can I find out?

Status
Not open for further replies.

KarenLloyd

Programmer
Nov 23, 2005
141
GB
Hiya

I'm having to revisit the issue of packing and reindexing files and needing exclusive access.

I have one situation where the users either do not want to come out of the application or a computer in another part of the building has been left in the application.

It is vital to the performance of the system that they reindex periodically, but they get frustrated at the "File Access Denied" message when everyone else is meant to be out.

I have spent hours looking for the answer, and learnt a few new bits and found a few more functions I'd forgotten existed. It's been an interesting morning, but I still don't have the answer to my question...

Is there any way to find out the workstation name that has a file open across the network? (This would need to work from another workstation, not the server, no-one works on the server)

Can anyone point me in the right direction please? That is, if there is one?

Karen

 
Other than writing you own audit routine which would track which user has which table(s) in USE, I don't know of any VFP solution.

But I do use a 3rd party (non-VFP) tool to tell me exactly that.
I use WhoHasNT ( )

I occassionally have a negligent user who messes things up and I need to find out who did it. This tool allows me to do so.

Good Luck,
JRB-Bldr
 
Here's what I do in one application that's updated frequently: have the program check at startup check for the presence of a file named SHUTDOWN.TXT. If it exists, tell the user the app is down for maintenance right now and then QUIT. This prevents users from starting it up when I don't want them to. There's also an application-wide timer whose Timer event does something similar: if that file exists, tell the user they have two minutes to finish what they're doing, then start another timer that has an interval of two minutes, the Timer method of which exits the app.

So, when I need to install a new version, I simply create a file called SHUTDOWN.TXT, wait a few minutes, then do what I need to do and erase the file so everyone can get back in.

Doug
 
I have one situation where the users either do not want to come out of the application or a computer in another part of the building has been left in the application.

To resolve that issue I have put timers into the application's forms which will periodically look for the time of day.
If it is after the daily 'drop-dead' time of the day, then I run a FUNCTION which will close all forms, close all data tables, and QUIT.

Maybe others will have even better ways to handle these 'negligent' users.

Good Luck,
JRB-Bldr
 
Maybe others will have even better ways to handle these 'negligent' users.

I also do something like what JRB-Bldr and Doug do. But there are a few complications.

In my case, I give the users 10 minutes warning before shutting down. But that means I also have to guard against users who launch the application within that 10-minute period. Plus, the administrator (the user who initiated the shutdown) has the ability to cancel the shutdown during the warning period, which complicates things slightly. Also, I take care to roll back any transactions and revert any buffered edits at the time of the shutdown. None of these are serious issues, of course.

Karen, I know this doesn't answer your original question, but it does reflect the approach which I think many developers prefer.

Mike

__________________________________
Mike Lewis (Edinburgh, Scotland)

Visual FoxPro articles, tips, training, consultancy
 
Hi

Thank you JRB-Bldr, Doug and Mike for your replies. You have provided a helpful insight into the methods that I think many people would use.

I do already use timers / timeouts to release certain screens. So I can adapt my grid builder class to pick up a system timeout when I need to get everyone out, and use a "lock out" file to prevent them going back in til the reindexing has finished.

Obviously there would be more to it than that, but the way forward will have to be a combination of these things.

The link from JRB-Bldr has also led me to look into Net File and find more related information, but I'm not sure how far I will go with that just yet.

You have certainly given me food for thought...

Thanks again.

Karen
 
In the end at a customer also having an IT department and some programmers, it often turned out a table was still open in their VFP IDE, so application side lock out could not get out every user.

See here, there is a tool giving you users having a file open from network clients:
Notice the notice: 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.

Bye, Olaf.
 
Thank you, Olaf.

I will cetainly check out this link.

I think the problem that I am going to have with these such tools is that they need to be run from the file server, which may not be possible in this situation.

As I am not involved with the hardware or network setup, I will need to speak with my client's IT provider to see what is possible.

Karen
 
the problem that I am going to have with these such tools is that they need to be run from the file server

The tool that I use WhoHasNT is typically run from a workstation - not from the file server itself.
To get its full functionality you need to install a WhoHasNT 'server' on the workstation, but it does not need to be on the network servers themselves. However your user privileges on the network may need to be addressed in order for you to have full capability (much like Olaf mentions above).

Good Luck,
JRB-Bldr
 
Hello Karen,

I'm not sure you need to run it on the file server, the precondition made is the user needs to be an adminstrtator on the file server. It would make sense to run this on the file server anyway and to be an on site administrator.

So yes, this is of limited use, when added into an application, I also did like the others with a timer and a lock out file. It's much easier, if you run a sql server backend. At le3ast that aspect does not byte you, SQL Server can cut off users and take a databasse offline, if needed.

Bye, Olaf.
 
OK. I only have a limited network to test on in the office, being a one (wo)man band. But I can ask for a selected user to be given administrator permissions on the customer's network so that they can use these functions

Thank you again JRB-Bldr and Olaf for your help.

Karen
 
If you want, you can take a look at an app I wrote using VFP for this.
Follow the link in my signature, then scroll down to the "Open File Lister". It has a some shortcomings, but it has some good examples of how to see who has files open and clear the connections if need be.


-Dave Summers-
[cheers]
Even more Fox stuff at:
 
Hi DSummZZZ

Thanks very much for pointing me to your app and website.

I have downloaded the Open File Lister and tried it out on my network. I can get the form loaded and see the server, but as I'm not using NT I get "Requires Windows NT" on one (my most ancient) computer and "Error number: 87" on my (slightly less ancient) laptop. These are the only two that I currently have networked.

I will try this app on the customer network, if that's OK. It will be fantastic if they have the right environment for me to use this on. (Fingers crossed eh!) In the mean time, I'll have to carry on with the development work.

Cheers Dave. I will come back to you again when I've had the chance to try it out properly.

Karen
 
Karen,

I hope it works out for you.

As for that message, you may be able to step through the code and just bypass that RETURN. I don't know for sure if it's necessary or not, as I think the oldest version it would run on is Windows NT. It has worked fine for me on NT, W4, W2000, XP and W7.


-Dave Summers-
[cheers]
Even more Fox stuff at:
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top