Windows OS Hub
  • Windows
    • Windows 11
    • Windows 10
    • Windows Server 2025
    • Windows Server 2022
    • Windows Server 2019
    • Windows Server 2016
  • Microsoft
    • Active Directory (AD DS)
    • Group Policies (GPOs)
    • Exchange Server
    • Azure and Microsoft 365
    • Microsoft Office
  • Virtualization
    • VMware
    • Hyper-V
    • Proxmox
  • PowerShell
  • Linux
  • Home
  • About

Windows OS Hub

  • Windows
    • Windows 11
    • Windows 10
    • Windows Server 2025
    • Windows Server 2022
    • Windows Server 2019
    • Windows Server 2016
  • Microsoft
    • Active Directory (AD DS)
    • Group Policies (GPOs)
    • Exchange Server
    • Azure and Microsoft 365
    • Microsoft Office
  • Virtualization
    • VMware
    • Hyper-V
    • Proxmox
  • PowerShell
  • Linux

 Windows OS Hub / Windows 11 / How to Unlock File or Folder Locked by SYSTEM or App Process

September 30, 2025

How to Unlock File or Folder Locked by SYSTEM or App Process

Sometimes, when you try to delete, rename, or move a file or folder in Windows, you may receive a message saying the file is busy, locked, or in use by another process. The name of the program that is holding the file open is most often listed directly in the error. To unlock a file, simply close this program. However, it is possible that the required file is being used (locked) by an unknown or system process.

Contents:
  • Find Out Which Process is Locking a File or Folder in Windows
  • How to Unlock a File Using Process Explorer
  • How to Release a File Lock Using the Handle Tool
  • Locked Files in a Shared Network Folder

If a program opens a file in exclusive mode, the file system blocks other applications from performing input/output (I/O) operations on that file. If you attempt to edit or delete a locked file, a message appears indicating that the file is already in use.

File/Folder in Use. The action can’t be completed because the file is open in another program. Close the folder or file and try again.

File in Use. The action can’t be completed because the file is open in another program

In this example, it is obvious which app has locked the file. To release the file, just close this program.
If a file is locked by the operating system or a process running with SYSTEM privileges, the “file is in use” message typically doesn’t display the specific app name responsible for the lock.

The action can’t be completed because the file is open in SYSTEM.
Close the file and try again.

The action can’t be completed because the file is open in SYSTEM

The process cannot access the file XXX because it is being used by another process.

error in powershell script: file in being used by another process

When a Windows process opens a file, a file descriptor (handle) is assigned to its input/output (I/O) stream. The Window API allows you to send a signal to the file system to release the handle and unlock the file.

Forcibly closing a file handle may result in unsaved data, corruption of the open file, or failure of the application or operating system. Don’t do it on a production server unless you have tested it in advance.

Find Out Which Process is Locking a File or Folder in Windows

There are several built-in Windows tools that allow you to identify the process (program) that is currently using a file.

The Resource Monitor tool (resmon.exe) can be used to identify which files are open and by which processes:

  1. Run the resmon.exe and go to the CPU tab
  2. In the Associated Handles section, type the name of the locked file or folder in the search bar.
  3. The name of the process currently using the file will appear in the search results window.
  4. You can kill this process immediately by clicking on it and selecting End Process. resmon: find process that used a file

How to Unlock a File Using Process Explorer

It is not always possible to simply kill the process that has locked the file, especially on servers. The ProcessExplorer tool is useful for identifying the process that has locked a file and releasing it without terminating the parent process.

Download ProcessExplorer from the Microsoft website or install it using the WinGet package manager:

Winget install Microsoft.Sysinternals.ProcessExplorer

install process explorer using winget

  1. Run the ProcessExplorer ( procexp.exe ) as an administrator.
  2. Select Find -> Find Handle or DLL (or press Ctrl-F); process explorer - find handle or dll
  3. Specify the file name you want to unlock and click Search
  4. Select the file you need. The process that opened the file will be highlighted in the process tree.
  5. You can stop this process by right-clicking on it and selecting Kill Process Tree.
  6. However, you can try to close the file handle without terminating the process. The file handle that you searched for is automatically highlighted in the bottom panel of Process Explorer
  7. Right-click the handle and select Close handle. Confirm closing the file. release a file handle using process explorer
If the bottom panel with the list of open process handles is not displayed in the Process Explorer, enable the option View -> Lower Pane View -> Handles.

So, you closed the file handle without terminating the parent process. You can now delete or rename the file.

How to Release a File Lock Using the Handle Tool

Handle is a Microsoft console tool that can identify the process locking your file and remove the lock by releasing the handle.

  1. Download or install the Handle utility using WinGet: winget install Microsoft.Sysinternals.Handle
  2. Open the command prompt as an administrator and run the following command: handle64.exe > listproc.txt
  3. This command saves the list of open handles to a text file.
  4. You can list all the open file handles in a specific directory (the -u option shows the name of the user who ran the process): Handle.exe -u -a C:\Some\Path  handle: get file handles in specific folderOr, list the open handles for a specific process (which files the process holds open): handle.exe -p winword.exe
  5. Open listproc.txt in any text editor and find the line that contains the name of the locked file. Copy the file handle ID in hex format. Then, scroll up to the section where the process that owns the handle is shown and write down its ID. It is most likely that a process run as system will have PID 4.get open file handle id using handle64.exe
    Handle.exe may return the following for some system processes: wininit.exe pid: 732 \<unable to open process>. It means that you cannot get any information about these system processes (even as an administrator). To retrieve handles for files opened by such processes, run the cmd.exe with SYSTEM privileges and then list the handles again
  6. Then, return to the command prompt and reset the file handle using its HandleID and ProcessID: handl64e.exe -c HandleID -p ProcessID For example: handl64e.exe -c 18C -p 18800close file handle on windows 10
  7. The tool will prompt you to confirm that you want to close the file description for a specific process. Confirm it by pressing y -> enter.

If Windows (or the running program) responds properly to the file closing, you can unlock your file without needing to kill the process or reboot the server/computer.

The following PowerShell script can be used to automatically identify the process that has locked the file:

$file = "C:\scripts\out_file.txt"
$handleOutput = handle.exe $file
$pidList = @()
$handleOutput | ForEach-Object {
if ($_ -match "^(.*)\s+pid:\s*(\d+)") {
$name = $matches[1].Trim()
$processId = $matches[2]
if ($pidList -notcontains $processId) {
Write-Host "ParentProcess PID $processId $name"
$pidList += $processId
}
}
}

powershell script to find process that locked a file

Locked Files in a Shared Network Folder

Most of the above tools will not show who has opened a file exclusively in a shared folder on a computer if the file is being accessed over the network. This applies to both simple and admin shared folders.

Use the following command to list the files that have been opened over the network:

net file

or

openfiles /query /fo

openfiles: list files open remotely

To close an open (locked) file, run:

net file [id] /close

net file close

Learn more about how to find and close open files in a shared network folder.

7 comments
11
Facebook Twitter Google + Pinterest
Windows 10Windows 11Windows Server 2022
previous post
Configuring Password Policy in Active Directory Domain
next post
This App Has Been Blocked for Your Protection in Windows

Related Reading

How to Repair Windows Boot Manager, BCD and...

March 11, 2024

PowerShell: Get Folder Size on Windows

April 2, 2024

Fix: The Computer Restarted Unexpectedly or Encountered an...

May 16, 2024

How to Download Offline Installer (APPX/MSIX) for Microsoft...

March 12, 2024

Windows Doesn’t Automatically Assign Drive Letters

March 15, 2024

How to Clean Up System Volume Information Folder...

March 17, 2024

Install and Manage Windows Updates with PowerShell (PSWindowsUpdate)

March 17, 2024

Managing Administrative Shares (Admin$, IPC$, C$) on Windows

March 15, 2024

7 comments

OS March 29, 2021 - 8:35 am

I made an PowerShell function for unlocking locked files https://github.com/ztrhgf/useful_powershell_functions/blob/master/Unlock-File.ps1 based on this article. Thanks for inspiration 🙂

Reply
admin March 30, 2021 - 4:04 am

Nice and very fast work 🙂

Reply
Shlomi March 31, 2021 - 4:54 pm

Nice!! I download the script
thank you!

Reply
Shlomi March 31, 2021 - 4:54 pm

Amazing! thank you

Reply
Naven April 11, 2021 - 11:06 am

Good one without installing third party softwares..!!

Reply
Tistou January 20, 2022 - 3:31 pm

Don’t work with a file open by System pid : 4… 🙁

Reply
Nossy July 24, 2024 - 6:52 am

Is there any way to automate this so it automatically unlocks the file when its locked?

Reply

Leave a Comment Cancel Reply

join us telegram channel https://t.me/woshub
Join WindowsHub Telegram channel to get the latest updates!

Recent Posts

  • How to Get Windows 10 Extended Security Updates After End-Of-Life

    September 24, 2025
  • Blocking NTLM Connections on Windows 11 and Windows Server 2025

    September 23, 2025
  • Windows Stucks at ‘Getting Windows Ready, Don’t Turn Off Computer’

    September 15, 2025
  • Clean Up ETL Log Files in ProgramData

    September 9, 2025
  • Fix: Slow Startup of PowerShell Console and Scripts

    September 3, 2025
  • DPI Scaling and Font Size in RDP (RDS) Session

    August 27, 2025
  • Proxmox: Share a Host Directory with VMs via VirtioFS

    August 18, 2025
  • How to Find AD Users with Blank Passwords (Password-Not-Required)

    July 24, 2025
  • Run Elevated Commands with Sudo on Windows 11

    July 16, 2025
  • Find a Process Causing High Disk Usage on Windows

    July 15, 2025

Follow us

  • Facebook
  • Twitter
  • Telegram
Popular Posts
  • How to Repair EFI/GPT Bootloader on Windows 10 or 11
  • How to Restore Deleted EFI System Partition in Windows
  • Network Computers are not Showing Up in Windows 10/11
  • Install and Manage Windows Updates with PowerShell (PSWindowsUpdate)
  • How to Download Offline Installer (APPX/MSIX) for Microsoft Store App
  • Updating List of Trusted Root Certificates in Windows
  • Fix: Windows Cannot Connect to a Shared Printer
Footer Logo

@2014 - 2024 - Windows OS Hub. All about operating systems for sysadmins


Back To Top