File Open in Another Program? Find the Process Locking It
Direct answer: On Windows 11, open Resource Monitor (Win + R, then resmon), choose CPU → Associated Handles, and search for part of the filename. On macOS, run lsof "/path/to/file" in Terminal. Check the process name and exact path, then save your work and close the app normally. An open handle is a clue. It may be harmless, or it may belong to an app that is still writing.
Use the checks below before retrying a rename, move, or eject. Save work before restarting any app or the computer.
Why files stay locked after you close an app
Closing a document window may leave the app or a background helper running. Explorer and Finder previews, search indexers, antivirus tools, and sync clients can all open files independently.
On Windows, the sharing mode used by an open handle can prevent another program from renaming or deleting the file. On macOS, an open file can keep a volume busy even though many ordinary file paths can be removed while an application still has the file open.
What to do once you identify the process
| Process | What to try first |
|---|---|
| Editor or viewer | Save your changes, close the file, then quit the app normally. |
| Explorer or Finder preview | Deselect the file and close the preview pane or Quick Look window. |
| Sync client | Check sync status and allow pending transfers to finish. Use the client’s pause control if needed. |
| Database, virtual machine, or system service | Use the owning app’s normal shutdown or wait for background work to finish. On a managed machine, ask the administrator. |
Method 1 (Windows 11): Use built-in Resource Monitor (no downloads)
Windows 11 includes Resource Monitor, which can search for matching handles visible to it.
- Press
Win + R, typeresmon, and press Enter. - Click the CPU tab at the top.
- Expand the Associated Handles bar near the bottom.
- Type part of the locked file or folder name into the Search Handles box.
- Wait for the results. Look at the Image, PID, and Handle Name columns to confirm the exact file path and executable holding it.
If explorer.exe is the culprit: Sometimes deselecting the file or closing Preview pane (Alt + P) and Details pane in File Explorer can release the handle. If Explorer still refuses to let go, open Task Manager, select Windows Explorer, and click Restart task instead of rebooting Windows.
Method 2 (Windows 11): Microsoft PowerToys File Locksmith
If you run into locked folders often, Microsoft's official PowerToys utility includes File Locksmith, a right-click context tool and command-line checker built specifically for this job.
Using the Explorer right-click menu
- Enable File Locksmith inside PowerToys Settings.
- Right-click the stuck file or folder in File Explorer (click Show more options if using the classic menu, or Unlock with File Locksmith directly in Windows 11).
- File Locksmith lists matching processes it can access. Click Restart as administrator inside the File Locksmith window if you suspect a background service or another Windows account holds the lock.
- Save work and quit the blocking app normally. Refresh File Locksmith to see whether it still holds the file.
Using File Locksmith from the terminal
PowerToys adds its CLI binary to PATH automatically, so scripts and terminal sessions can inspect locks directly:
# Inspect which processes lock a specific file or directory
PowerToys.FileLocksmith.CLI.exe "C:\Work\Q4-Archive\budget.xlsx"
# Machine-readable JSON output for automation scripts
PowerToys.FileLocksmith.CLI.exe --json "C:\Work\Q4-Archive"
If an automated move script keeps colliding with an open editor or indexing pass, File Locksmith's CLI can wait cleanly for the handle to clear instead of killing processes prematurely:
# Wait up to 30 seconds for the lock to release (exits with code 1 on timeout)
PowerToys.FileLocksmith.CLI.exe --wait --timeout 30000 "C:\Work\Q4-Archive"
A successful wait only reflects the check at that moment. Handle normal file-operation errors in your script because a process can reopen the file.
Method 3 (Windows CLI): Sysinternals Handle vs. openfiles
If PowerToys is unavailable and your administrator allows standalone diagnostic tools:
- Microsoft Sysinternals
handle.exe: A standalone single executable that inspects kernel handles from PowerShell or Command Prompt after you download and extract it:
Run the shell as Administrator so system and service handles are visible.handle.exe -nobanner "C:\Work\Q4-Archive" - Why you rarely want
openfiles /querylocally: Windows includes a built-in command calledopenfiles, but by default it only lists files opened over network shares (openfiles /query). Enabling it for local handles requires turning on object tracking as Administrator and rebooting the computer, which adds system-wide overhead. Use Resource Monitor or Handle for an ordinary local check.
Method 4 (macOS): Trace open handles with Terminal lsof
On macOS, lsof lists open files. It can help identify processes when Finder says an item is in use or refuses to eject an external drive.
Open Terminal (Cmd + Space, type Terminal) and pick the scope you need:
# 1. Check a single locked file
lsof "/Users/yourname/Desktop/client-deck.pdf"
# 2. Scan an entire folder or external drive recursively (+D checks subdirectories)
sudo lsof +D "/Volumes/Backup-SSD"
Tip: +D walks every nested directory under that path, so avoid pointing +D at / or your entire home folder—target the specific project folder or /Volumes/DriveName instead.
Read COMMAND and PID to identify the process and NAME to confirm the path. In FD, a suffix such as r, w, or u indicates read, write, or read/write access. Access mode alone does not establish that a lock exists or that a write is in progress.
Save your work and quit the app normally. If a preview is open, close Quick Look first. For an unresponsive user app, Activity Monitor offers Quit and Force Quit. Force Quit can lose unsaved changes.
Method 5 (macOS GUI): Activity Monitor's Open Files and Ports
If you already have a suspect app open (say an editor, browser helper, or sync client) and want a graphical view without Terminal:
- Open Activity Monitor (
/Applications/Utilities/Activity Monitor.app). - Locate the suspect app or background helper and double-click it .
- Switch to the Open Files and Ports tab.
- Scroll the list to verify whether the stubborn file path sits inside that process's open file table.
- Switch back to the app itself and close that document tab or quit the app cleanly with
Cmd + Q.
Quick reference: which method to pick first
| Your situation | Windows 11 best choice | macOS best choice |
|---|---|---|
| Can't delete/rename one file right now | resmon -> CPU -> Associated Handles | lsof "/path/to/file" in Terminal |
| Whole folder or external drive won't eject/move | PowerToys File Locksmith on the folder | sudo lsof +D "/Volumes/Drive" |
| Clean up hung Finder/Explorer preview locks | Toggle off Explorer Preview Pane or restart Explorer | Close Quick Look and the Finder window |
| Scripting pre-checks before file moves | PowerToys.FileLocksmith.CLI.exe --wait --json | Inspect lsof results, then handle move or copy errors |
| Locked-down workstation (no third-party installs) | Built-in Resource Monitor (resmon) | Activity Monitor -> Inspect -> Open Files & Ports |
Why checking open handles matters before bulk file moves or handoffs
A bulk move can stop or skip items when one file is unavailable. Save and close active files, wait for sync to finish, and preview your changes before moving originals. Keep a separate backup of important files and review the operation log for errors.
For a worked example of a preview-first workflow, see how to organize screenshots on Windows. If your goal is a Microsoft 365 handoff, see how to prepare files for SharePoint and OneDrive.
Disclosure: EnlightPixel publishes SortSage for rules-based file organization and PathReady for preparing a separate local handoff copy. Use the OS diagnostics above to identify processes holding files open.
Frequently asked questions
Does restarting Windows Explorer delete my files or close other apps?
Restarting Explorer does not delete files. It can close Explorer windows or interrupt file operations started in Explorer, so finish or cancel those first. Retry only after Explorer restarts.
Why won't PowerToys File Locksmith or Resource Monitor find anything, even though the file is still locked?
Two common causes: either the file is held by an elevated service (Administrator / SYSTEM) and you ran the inspector as a standard user (click Restart as administrator in File Locksmith or run elevated resmon), or the lock lives on a remote SMB/NAS server holding the file open on the host side rather than locally on your PC.
On macOS, why did lsof return nothing when Finder says the volume can't be ejected?
Your account may lack permission to see relevant processes or traverse the entire volume. If you are authorized to administer the Mac, try sudo lsof +D "/Volumes/YourDrive" on the correct mount path. Wait for backup or sync activity to finish before retrying. An empty result is a snapshot, and it can miss transient activity.
References
Related articles
How to Automatically Organize Screenshots on Windows (Safely)
Find where Windows saves screenshots, then organize captures by year, month, and project with PowerShell or SortSage.
Read Choosing softwareBest Desktop Productivity Software in 2026 (Mac & Windows)
Discover desktop productivity software for macOS and Windows in 2026. Compare launchers, workspaces, notes and file tools, with clear limits and maker disclosure.
Read Studio notesWhy Independent Software Studios Still Matter in 2026
Why independent software studios matter: focused tools, personal attention and clear product terms for macOS and Windows, across one-time and subscription plans.
Read