Get list of users locking a file on server

Technical support and scripting issues

Moderators: JRL, Dorian (MJT support)

Post Reply
User avatar
Grovkillen
Automation Wizard
Posts: 1132
Joined: Fri Aug 10, 2012 2:38 pm
Location: Bräcke, Sweden
Contact:

Get list of users locking a file on server

Post by Grovkillen » Wed Jan 28, 2015 9:17 pm

Hi,

I'm sure this is not possible but is it some way that I can get user names of the people locking a certain file on the server? I mean without accessing the server itself?

Word and Excel files that are opened by others will prompt me the user name upon opening the file. How does that work?

Open for discussion.
Let>ME=%Script%

Running: 15.0.27
version history

User avatar
JRL
Automation Wizard
Posts: 3532
Joined: Mon Jan 10, 2005 6:22 pm
Location: Iowa

Re: Get list of users locking a file on server

Post by JRL » Fri Jan 30, 2015 7:08 pm

I used to have a program to do something like this, it was one of my first big programs ten or more years ago. It didn't work out very well. The premise was that I had an executable that ran on the server. The program continuously polled a specific folder for text files of a specific name. The text file contained the path and name of a file that was locked on the server. The program then used DOS "net file" to remove the file lock.

On the client side I had a program that opened a browse dialog so the user could browse to the locked file. Selecting the file to be closed created the text file in the specific folder on the server. The server opened the text file then closed the file named within.

The main problem I had was users abusing their file closing privileges even though I had a big warning in the dialog telling them they should not close a file unless they were absolutely certain they were the only person who had the file open. Back in earlier versions of Windows we sometimes had the problem of a file was closed but the lock remained.

So user B wants to change a file that user A has open. User B unlocks the file, opens the file, makes a change, saves and closes. User A has no knowledge of this and continues to work on the file. When user A saves and closes the file the changes made by user B no longer exist. User B however, does not know this until a problem arises some time in the future. I tried to find a way to tell the users who had the file open but never did find that method (so I can't answer your original question). Without knowing who has the file open user B has to go searching for the person (user A) that has the file open. If they have to do that anyway, they might as well just have the person close the file when they find them.

Word and Excel files on the network have their own reporting scheme. For example, when you open a networked Excel file, If you then browse to the file in Windows Explorer you'll see that the date and time on the file has been updated. Used to be that they placed a temp file beside the Excel file, today they just update the file. The Excel file updates when you open it because your Excel user information has been inserted into the file. When someone else opens the same file they can only open it as read only and they see your Excel user information (not network user information). If you leave the file without making any changes, the file reverts to its original date and time.

All-in-all my experience with this is that though it sounds like a good idea it really defeats the built in network file safeguards and causes more headaches than it resolves. The best thing is to get on the server and use the provided file management tools to view files in use. From there you can see who has the file open and you can unlock it if necessary. If you don't have physical access to the server you might be able to call up "Computer Management" on your local computer and manage files on the server like this:

Control Panel > Administrative Tools > Computer Management.

Under the Action Tab pick "Connect to another computer..."

Type in the server name or browse to it. Pick "Ok". Wait for the window to refresh.

Then in the navigation pane pick System Tools > Shared Folders > Open Files.

From here you should be able to see who has any file open.

Hope this helps.
Dick

User avatar
CyberCitizen
Automation Wizard
Posts: 724
Joined: Sun Jun 20, 2004 7:06 am
Location: Adelaide, South Australia

Re: Get list of users locking a file on server

Post by CyberCitizen » Sun Feb 01, 2015 4:22 am

The information you see is the Microsoft Office User Registration Information.

Eg when you first open Office it asks for your name etc. In a corp environment it could be any user that completed the first sign up. Get it all to often when its actually another user that has the file open, but the name is incorrect.

What you need to do is have a script that updates the registry entry on login to match the current logged on user name, then that way the information is correct when the file is locked etc.

Without having login rights on the server to get into computer management open shares you can't tell who has it locked. At least in my many years in IT I haven't found any real easy way without having those rights.
FIREFIGHTER

Post Reply
Sign up to our newsletter for free automation tips, tricks & discounts