windows 找出谁在网络共享上锁定文件
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/581219/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Find out who is locking a file on a network share
提问by olorin
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.
问题是:网络共享在 NAS 上,所以我无法登录。我需要一个工具来远程找出谁在锁定文件。每次都重启NAS是不切实际的,因为有多个用户。
Handle.exe, Process Explorer and PsFileseems to be limited to files on the local machine, so they don't work for me.
Handle.exe、 Process Explorer 和PsFile似乎仅限于本地计算机上的文件,因此它们对我不起作用。
回答by Dirk Paessler
Just in case someone looking for a solution to this for a Windows based system or NAS:
以防万一有人为基于 Windows 的系统或 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):
Windows 中有一个内置功能,可以显示本地计算机上的哪些文件被远程计算机打开/锁定(通过文件共享打开文件):
- Select "Manage Computer" (Open "Computer Management")
- click "Shared Folders"
- choose "Open Files"
- 选择“管理计算机”(打开“计算机管理”)
- 点击“共享文件夹”
- 选择“打开文件”
There you can even close the file forcefully.
在那里你甚至可以强行关闭文件。
回答by Jason Pearce
On Windows 2008 R2 servers you have two means of viewing what files are open and closing those connections.
在 Windows 2008 R2 服务器上,您可以通过两种方式查看打开的文件和关闭这些连接。
Via Share and Storage Management
通过共享和存储管理
Server Manager > Roles > File Services > Share and Storage Management > right-click on SaSM > Manage Open File
服务器管理器 > 角色 > 文件服务 > 共享和存储管理 > 右键单击 SaSM > 管理打开的文件
Via OpenFiles
通过 OpenFiles
CMD > Openfiles.exe /query /s SERVERNAME
CMD > Openfiles.exe /query /s SERVERNAME
See http://technet.microsoft.com/en-us/library/bb490961.aspx.
请参阅http://technet.microsoft.com/en-us/library/bb490961.aspx。
回答by Baodad
PsFiledoes work on remote machines. If my login account already has access to the remote share, I can just enter:
PsFile可以在远程机器上工作。如果我的登录帐户已经可以访问远程共享,我可以输入:
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:
(将“remote-share”替换为您的文件服务器的名称),它将列出该共享上每个打开的文档,以及打开它的人,以及文件 ID(如果我想强制关闭文件)。对我来说,这是一个很长的列表,但可以通过输入路径的一部分来缩小范围:
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.
这有点棘手,因为在我的情况下,这个远程共享在我的本地机器上作为 Z: 挂载,但 psfile 标识在远程文件服务器上定义的路径,在我的情况下是 I:(你的会有所不同) . 我只需要梳理我第一次 psfile 运行的结果以查看它返回的一些路径,然后使用部分路径再次运行它以缩小结果范围。
Optionally, PsFile will let you specify credentials for the remote share if you need to supply them for access.
或者,如果您需要提供用于访问的凭据,PsFile 将允许您为远程共享指定凭据。
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.
最后,一个鲜为人知的提示:如果有人在 Windows 资源管理器中单击文件并剪切或复制文件以将其粘贴到其他地方,该行为也会锁定文件。
回答by Jones
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
如果只是在任何特定时间知道/查看文件中的人(如果您使用的是 Windows),只需选择文件“查看”作为“详细信息”,即而不是缩略图、图块或图标等。一次在“详细信息”视图中,默认情况下会显示您;- 文件名 - 大小 - 类型和 - 修改日期
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.
这在使用共享 MS Access 数据库时特别有用。
回答by Jones
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.
会话由 NAS 设备处理。您要问的是取决于 NAS 设备,与 Windows 无关。您必须查看您的 NAS 固件以了解它支持的内容。唯一的另一种方法是嗅探数据包并自己解决。
回答by olorin
Partial answer: With Process Explorer, you can view handles on a network share opened from your machine.
部分答案:使用 Process Explorer,您可以查看从您的机器打开的网络共享上的句柄。
Use the Menu "Find Handle" and then you can type a path like this
使用菜单“查找句柄”,然后您可以键入这样的路径
\Device\LanmanRedirector\server\share\
回答by Javier
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.
听起来你有同样的问题,我试图在这里解决。就我而言,它是一个 Linux 文件服务器(当然运行 samba),所以我可以登录并查看哪个进程正在锁定文件;不幸的是,我还没有找到如何在不终止负责会话的情况下关闭它。AFAICT,Windows 客户端“认为”它已关闭;但没有费心告诉文件服务器。
回答by R.Alonso
Close the file e:\gestion\yourfile.dat
, open by any user (/a *
)
关闭文件e:\gestion\yourfile.dat
,由任何用户打开 ( /a *
)
openfiles /disconnect /a * /op "e:\gestion\yourfile.dat"