无法删除、移动或对文件执行任何操作,因为它被进程锁定?使用本文中讨论的各种方法找出(Find)哪个进程正在锁定Windows 11/10
很多时候,当我们尝试对文件执行操作(删除、重命名、复制等)时,我们会得到一个File in Use对话框,显示提示“该操作无法完成,因为该文件已在另一个程序中打开(The action can’t be completed because the file is open in another program)“。在某些情况下,它会显示正在使用该文件的进程或程序名称。但是,很多时候,它没有。
现在,如何判断哪个进程打开了文件?如果紧急,则需要识别锁定文件的进程,然后结束该进程以修改目标文件。在本指南中,我们将讨论检查在Windows 11/10中保存文件的进程的不同方法。
如何判断哪个进程正在锁定或使用Windows 11/10
Windows 11/10中锁定文件的进程的不同方法:
- 使用Resource Monitor(Resource Monitor)检查锁定文件的进程。
- 使用 SysInternals Process Explorer(Use SysInternals Process Explorer)来识别锁定文件的进程。
- 使用句柄(Handle)工具通过命令提示符查找。(Command Prompt)
- 使用 OpenedFilesView(Use OpenedFilesView)免费软件来识别持有文件的进程。
现在让我们详细说明这些方法。
1]使用资源监视器(Resource Monitor)检查(Check)锁定文件的进程
使用Resource Monitor,您可以识别锁定文件的进程或服务。它是Windows 10中的内置实用程序,可帮助您监控 CPU 使用率、内存、磁盘网络、文件句柄等。
按Windows + R热键打开运行(Run)应用程序,然后在其中键入resmon。按确定按钮,资源监视器(Resource Monitor)将打开。
在Resource Monitor窗口中,转到CPU选项卡并展开Associated Handles选项。现在,在搜索框中,键入显示被进程锁定的文件的名称,然后按Enter按钮。它将向您显示保存目标文件的进程列表。
您可以右键单击该进程并选择“结束进程(End Process)”选项来结束它。该过程结束后,尝试对先前锁定的文件执行您想要的操作。
2]使用SysInternals Process Explorer(Use SysInternals Process Explorer)识别锁定文件的进程
识别保存文件的进程或服务的另一个选项是SysInternals Process Explorer。它是一种高级实用程序,用于查找有关系统上正在运行的进程的详细信息。要识别通过它保存文件的进程,您可以按照以下步骤操作:
首先,在您的 PC 上下载并运行SysInternals Process Explorer 。现在,在Process Explorer窗口中,转到File菜单并单击Find Handle or DLL选项。接下来,在Process Explorer Search(Process Explorer Search)对话框窗口中输入文件名,然后按Search选项。使用您输入的文件的所有进程都将显示在结果中。
右键单击“(Right-click)进程(Process)”选项卡中识别的进程,然后将其关闭。
现在,检查文件是否仍被进程持有或锁定。
相关:(Related:) 该进程无法访问该文件,因为它正被另一个进程使用。(The process cannot access the file because it is being used by another process.)
3]使用Handle工具通过命令提示符(Command Prompt)查找(Find)
Handle是一个基于命令的实用程序,用于判断哪个进程打开了文件。它基本上是上面讨论的SysInternals Process Explorer的命令行版本。您可以按照以下步骤使用此工具在命令提示符下检查保存文件的进程:
从microsoft.com(microsoft.com)下载 Handle并解压缩 ZIP 文件夹。现在,在解压缩的文件夹中打开 CMD(open CMD in the extracted folder)。在命令提示符(Command Prompt)中,输入具有以下语法的命令:
handle.exe -a -u <filename-with-path>
例如:
handle.exe -a -u "C:\Users\KOMAL\Documents\Sample Files\twc.pdf"
当您输入命令时,它将显示一个包含进程 ID 和用户名的文件的进程列表。
我尝试通过仅输入文件名而不输入完整路径来检查相同的内容,它起作用了。但是,它可能不适用于所有文件。因此,建议输入锁定文件的位置。
确定进程后,您可以从任务管理器(Task Manager)中将其关闭。
4]使用 OpenedFilesView(Use OpenedFilesView)免费软件来识别持有文件的进程
OpenedFilesView是一个可移植的应用程序,用于查看所有打开的文件和保存它们的进程。你可以下载它的ZIP文件夹,解压它,然后运行它的OpenedFilesView.exe文件来启动它的界面。然后它将显示所有当前打开的文件以及各自的详细信息,包括进程名称、进程 ID、进程路径、文件权限、目标文件路径等。
找到您的目标文件并检查哪个进程正在保存它。此外,您可以使用其查找( Find)选项快速搜索锁定的文件和相关的进程。找到进程后,右键单击该文件并关闭所有持有它的进程。
希望本指南可以帮助您确定保存文件然后关闭它的过程。
现在阅读:(Now read:) 删除锁定的文件,并修复文件被锁定的错误。
How to tell which Process is locking or using a File in Windows 11/10?
Unable to delete or move or perform any action on a filе because it is locked by a procesѕ? Find out which process is locking а file in Windows 11/10 using various methods discusѕed in this article.
Many times, when we attempt an action (delete, rename, copy, etc.) on a file, we get a File in Use dialog box showing a prompt that “The action can’t be completed because the file is open in another program“. In some cases, it will show the process or program name that is using the file. But, a lot of times, it doesn’t.
Now, how to tell which process has a file open? If it is urgent, you need to identify the process locking a file and then end the process to modify the target file. In this guide, we will be discussing different methods to check the process that is holding a file in Windows 11/10.
How to tell which process is locking or using a file in Windows 11/10
Here are the different methods to identify the process that is locking a file in Windows 11/10:
- Check the process that is locking a file using Resource Monitor.
- Use SysInternals Process Explorer to identify the process that is locking a file.
- Find out through Command Prompt using the Handle tool.
- Use OpenedFilesView freeware to identify the process holding a file.
Let’s elaborate on these methods now.
1] Check the process that is locking a file using Resource Monitor
Using Resource Monitor, you can identify the process or service locking a file. It is an inbuilt utility in Windows 10 that helps you monitor CPU usage, memory, disk network, file handles, etc.
Open Run app by pressing Windows + R hotkey and then type resmon in it. Press the OK button and Resource Monitor will open up.
In the Resource Monitor window, go to the CPU tab and expand the Associated Handles option. Now, in the search box, type the name of the file that is showing locked by a process and press Enter button. It will show you a list of processes holding the target file.
You can right-click on the process and select the End Process option to end it. After the process ends, try performing the action you wanted to on the previously locked file.
2] Use SysInternals Process Explorer to identify the process that is locking a file
Another option to identify the process or service holding a file is SysInternals Process Explorer. It is an advanced utility to find out detailed information regarding running processes on your system. To identify the process holding a file through it, you can follow below steps:
Firstly, download and run SysInternals Process Explorer on your PC. Now, in the Process Explorer window, go to the File menu and click on the Find Handle or DLL option. Next, enter the file name in the Process Explorer Search dialog window and press the Search option. All the processes that are using the file you entered will show up in the results.
Right-click on the identified process in the Process tab and then close it.
Now, check with the file if it is still held or locked by a process or not.
Related: The process cannot access the file because it is being used by another process.
3] Find out through Command Prompt using Handle tool
Handle is a command-based utility to tell which process has a file open. It is basically a command-line version of the above discussed SysInternals Process Explorer. You can follow the below steps to check the process holding a file in command prompt using this tool:
Download Handle from microsoft.com and extract the ZIP folder. Now, open CMD in the extracted folder. In the Command Prompt, enter a command with the following syntax:
handle.exe -a -u <filename-with-path>
For example:
handle.exe -a -u "C:\Users\KOMAL\Documents\Sample Files\twc.pdf"
As you enter the command, it will display a list of processes holding the file with process ID and username.
I tried to check the same by entering just the filename without the full path, it worked. But, it may not work for all files. So, it is recommended to enter the location of the locked file.
After identifying the process, you can close it from Task Manager.
4] Use OpenedFilesView freeware to identify the process holding a file
OpenedFilesView is a portable application to view all your opened files and the processes holding them. You can download its ZIP folder, extract it, and then run its OpenedFilesView.exe file to launch its interface. It will then display all currently opened files with respective details including process name, process ID, process path, file permissions, target file path, etc.
Locate your target file and check which process is holding it. Also, you can use its Find option to quickly search for a locked file and the associated process. After finding the process, right-click on the file and close all the processes holding it.
Hope this guide helps you identify the process of holding a file and then closing it.
Now read: Delete Locked Files, and fix File Is Locked error.