Find out who is locking a file on a network share
Asked Answered
R

9

152

I want to known who is locking a file on a network share.

Here is the problem : the network share is on a NAS, so I can't log on. I need a tool to find out remotely who is locking the file. It is not practical to reboot the NAS every time, because there are several users.

Handle.exe, Process Explorer and PsFile seems to be limited to files on the local machine, so they don't work for me.

Robins answered 24/2, 2009 at 10:19 Comment(0)
I
190

Just in case someone looking for a solution to this for a Windows based system or NAS:

There is a built-in function in Windows that shows you what files on the local computer are open/locked by remote computer (which has the file open through a file share):

  • Select "Manage Computer" (Open "Computer Management")
  • click "Shared Folders"
  • choose "Open Files"

There you can even close the file forcefully.

Iridissa answered 12/10, 2009 at 11:38 Comment(7)
You can even use Action -> Connect to another computer to the file on a NAS, and it even works with our linux based NAT! Why didn't I try this earlier?Robins
On Windows 2008 R2 go to Server Manager > Roles > File Services > Share and Storage Management > right-click on SaSM > Manage Open Files.Grooved
Just open a MMC console and add a Shared Folders Snap-in. You can connect to remote systems.Genealogy
For a domain share, this did not work. The wording seems to imply files located on your network shares.Aftertaste
I used an application called Unlocker to do this (the file was on the NAS). The app is here: filehippo.com/download_unlocker/tech and it worked for me but I can't vouch for this appCapful
"Computer Management/Shared Folders" didn't work for me until I connected to the remote computer. Worked perfectly fine on the NAS connecting to the UNC path, //server.Guilford
opening 'Open Files' requires admin permissionsPrelatism
G
63

On Windows 2008 R2 servers you have two means of viewing what files are open and closing those connections.

Via Share and Storage Management

Server Manager > Roles > File Services > Share and Storage Management > right-click on SaSM > Manage Open File

Via OpenFiles

CMD > Openfiles.exe /query /s SERVERNAME

See http://technet.microsoft.com/en-us/library/bb490961.aspx.

Grooved answered 21/12, 2012 at 17:8 Comment(6)
Great answer. I didn't know about Openfiles; it works much better than having to use psexec or similar remoting tools.Divergence
@Divergence ok but if it's a NAS, and not windows based! C:\>Openfiles.exe /query /s 10.0.0.1 <ENTER> ERROR: The Target system must be running Windows XP or above.Gumption
It is worth to notice that nodes "Roles" etc expands with delay.Orleans
Thanks for this, openfiles.exe also works on Windows Server 2012 R2. I couldn't find any other good guides on how to list the open files from a 2012 server, but this did the trick.Whomsoever
Nice CMD command, thanks for sharing! Windows 10 Enterprise comes with Openfiles.exe right out-of-the-box.Chough
Windows Server 2012: Server Manager > Tools > Computer Management > Shared Folders > Open Files - see list of open files in right-hand pane.Trula
S
26

PsFile does work on remote machines. If my login account already has access to the remote share, I can just enter:

psfile \\remote-share

(replace "remote-share" with the name of your file server) and it will list every opened document on that share, along with who has it open, and the file ID if I want to force the file closed. For me, this is a really long list, but it can be narrowed down by entering part of a path:

psfile \\remote-share I:\\Human_Resources

This is kind of tricky, since in my case this remote share is mounted as Z: on my local machine, but psfile identifies paths as they are defined on the remote file server, which in my case is I: (yours will be different). I just had to comb through the results of my first psfile run to see some of the paths it returned and then run it again with a partial path to narrow down the results.

Optionally, PsFile will let you specify credentials for the remote share if you need to supply them for access.

Lastly, a little known tip: if someone clicks on a file in Windows Explorer and cuts or copies the file with the intent to paste it somewhere else, that act also places a lock on the file.

Seals answered 21/5, 2013 at 15:38 Comment(2)
are there supposed to be double \ s?Sylvanus
@PsychoData, it's been a while since I posted this. I hope what I posted is correct. The \\ before the remote-share part look right, but the \\ in I:\\Human_Resources does look weird. Still, I think I had a reason for it when I posted. Try it out and let me know.Seals
C
15

If its simply a case of knowing/seeing who is in a file at any particular time (and if you're using windows) just select the file 'view' as 'details', i.e. rather than Thumbnails, tiles or icons etc. Once in 'details' view, by default you will be shown; - File name - Size - Type, and - Date modified

All you you need to do now is right click anywhere along said toolbar (file name, size, type etc...) and you will be given a list of other options that the toolbar can display.

Select 'Owner' and a new column will show the username of the person using the file or who originally created it if nobody else is using it.

This can be particularly useful when using a shared MS Access database.

Claviform answered 10/5, 2012 at 11:23 Comment(4)
In my case didn't work. I add the column and I see myself as the creator of the shared file in the remote resource, but was locked already by a workmate.Envy
This really only works well when the program they are in creates a lockfile (like MS Access) that will be owned by whoever is using it and not the original creator of the fileSylvanus
To save adding the column, you can see the same info if you view the file properties and look at the Details tab.Edeline
This works really well for things like MS Word files.Kurt
E
6

The sessions are handled by the NAS device. What you are asking is dependant on the NAS device and nothing to do with windows. You would have to have a look into your NAS firmware to see to what it support. The only other way is sniff the packets and work it out yourself.

Entomo answered 24/2, 2009 at 10:46 Comment(1)
Well this a good answer with common sense. Sadly this NAS does not offer this functionality.Robins
R
5

Partial answer: With Process Explorer, you can view handles on a network share opened from your machine.

Use the Menu "Find Handle" and then you can type a path like this

\Device\LanmanRedirector\server\share\
Robins answered 24/2, 2009 at 12:53 Comment(0)
R
2

sounds like you have the same problem i tried to solve here. in my case, it's a Linux fileserver (running samba, of course), so i can log in and see what process is locking the file; unfortunately, i haven't found how to close it without killing the responsible session. AFAICT, the windows client 'thinks' it's closed; but didn't bother telling the fileserver.

Radarscope answered 24/2, 2009 at 11:40 Comment(1)
Sounds likely : as far as I know our NAS used a custom linux distro.Robins
V
2

Close the file e:\gestion\yourfile.dat, open by any user (/a *)

openfiles /disconnect /a * /op "e:\gestion\yourfile.dat"

more in: http://dosprompt.info/commands/openfiles.asp

Vardhamana answered 21/12, 2017 at 18:43 Comment(0)
H
0

If you are wanting to know who is using files and folders, in general, on a server .. (i.e. not necessarily related to file shares)

There is this handle.exe facility from Microsoft:

https://learn.microsoft.com/en-us/sysinternals/downloads/handle

You have to have admin access on server to use this.

e.g. a command like this:

handle.exe -u d:\ABCApp\Environment22

Hiss answered 26/3, 2024 at 4:37 Comment(0)

© 2022 - 2025 — McMap. All rights reserved.