ThisCalculator

Everyday

File is Open in Another Program? Fix It

Updated · Standard formula, shown below

This article explains the “File is open in another program” error on Windows and macOS, what causes it, and how to fix it. You’ll learn how to find which program has the file locked, how to unlock it safely, and how to prevent the problem from recurring.

What Does the Error Mean?

When you try to delete, rename, or move a file and see “The action can’t be completed because the file is open in another program,” it means the operating system has an open handle to that file. A handle is a reference that a running process (like a word processor, media player, or even Windows Explorer itself) holds to the file for reading or writing. As long as any process holds a handle, the OS prevents changes to the file’s location or name to avoid corruption or data loss.

Common Causes of File Locks

Several everyday situations can leave a file locked:

  • An application is still running – even if you closed the document window, the program may still run in the background (e.g., Microsoft Word, Adobe Acrobat).
  • A background process is using the file – antivirus scanners, cloud sync clients (OneDrive, Dropbox), or search indexers may briefly hold a handle.
  • Windows Explorer preview pane – if you have the preview pane open and selected a file, Explorer may lock it.
  • A hung or crashed process – a program that stopped responding may still hold a lock.
  • Network or external drive issues – files on a network share or USB drive may be locked by another device or user.

How to Find Which Program Is Locking the File

Before you can unlock a file, you need to know which process is holding it. On Windows, the built-in tools are limited, but you can use the following methods:

  1. Use the built-in “Resource Monitor” – Press Ctrl+Shift+Esc to open Task Manager, go to the “Performance” tab, and click “Open Resource Monitor” at the bottom. In Resource Monitor, go to the “CPU” tab and expand “Associated Handles.” Type the file name in the search box to see which processes have a handle to it.
  2. Use the command line – Open Command Prompt as administrator and run handle.exe (a free tool from Microsoft Sysinternals) with the file name: handle.exe "C:\path\to\file.txt". This lists the process name and its PID.
  3. Use PowerShell – You can use the Get-Process cmdlet combined with the openfiles command, but this requires enabling the “Maintain Objects List” global flag first (not recommended for casual users).

On macOS, you can use the lsof command in Terminal: lsof /path/to/file. This shows the process name and PID that has the file open.

How to Unlock the File Safely

Once you know which process is locking the file, you can close it properly:

  1. Close the program normally – If it’s a visible application, save your work and quit it. Wait a few seconds, then try the file operation again.
  2. End the process via Task Manager – If the program is not responding, open Task Manager (Ctrl+Shift+Esc), go to the “Details” tab, find the process name from the handle search, right-click it, and choose “End Task.” Be aware that this may lose unsaved data.
  3. Restart Windows Explorer – If Explorer itself is the culprit (common with preview pane), you can restart it: in Task Manager, right-click “Windows Explorer” and choose “Restart.” This will not close your apps.
  4. Log off and back on – This closes all user processes and releases handles. It’s a safe but disruptive option.
  5. Reboot the computer – If nothing else works, a restart clears all handles. This is the most reliable fix.

Warning: Do not use third-party “unlocker” tools that force-close handles unless you are absolutely sure the process is not writing data. Forcing a lock off can corrupt the file or cause a system crash.

Preventing the Error in the Future

You can reduce the frequency of this error with a few habits:

  • Close programs completely – Use the app’s exit command, not just the close button on a window.
  • Disable the preview pane – In Windows Explorer, go to the “View” tab and uncheck “Preview pane.” This prevents Explorer from locking selected files.
  • Pause cloud sync – If you’re editing a file that’s being synced, pause the sync client temporarily.
  • Check for background processes – Some apps (like Adobe Creative Cloud, Steam, or antivirus) run background services that may scan files. You can exclude certain folders from scanning in your antivirus settings.
  • Eject external drives properly – Always use “Safely Remove Hardware” before unplugging a USB drive.

What to Do If the File Is Locked by a System Process

Sometimes the locking process is a system service (e.g., svchost.exe or SearchIndexer.exe). In that case, you should not end the process. Instead:

  • Wait a few minutes – Search indexing and antivirus scans are usually brief.
  • Restart the service – For Windows Search, you can restart the “Windows Search” service from the Services app (services.msc) as an administrator.
  • Check for pending operations – If the file is on a network share, ensure no other user has it open. On Windows, you can use the “Open Files” section in Computer Management (compmgmt.msc) under “Shared Folders” to see who has files open.

If the file is locked by System (PID 4), it might be a page file, hibernation file, or a system restore point. Do not force-unlock these; they are essential for Windows to run.

Frequently Asked Questions

Why does the error still appear after I closed the program?

Closing a window doesn’t always quit the process. Many applications (like Microsoft Word or Photoshop) keep running in the background for faster startup. Check the system tray (near the clock) for icons and quit them from there, or use Task Manager to see if the process is still listed.

Can I use a free tool to unlock files?

Yes, but with caution. Microsoft’s Sysinternals suite offers handle.exe and Process Explorer which are free and safe. Third-party tools like LockHunter or IObit Unlocker exist, but they force-close handles and can cause data loss if the process is writing. Always try the built-in methods first.

Why does this error happen with PDF files so often?

PDF readers often keep a lock on the file even after you close the viewer, especially if the PDF is still in the browser’s download cache or if a browser plugin is holding it. Also, some PDF editors lock the file for editing until you explicitly close the document.

Does this error occur on macOS?

Yes, macOS shows a similar message: “The operation can’t be completed because the item is in use.” You can use the lsof command to find the process, then quit it normally. Restarting the Mac also clears all locks.

Can I delete a locked file by renaming the folder first?

No. The lock is on the file itself, not the path. Renaming the folder will also fail because the file handle is tied to the file object. You must release the handle first.

Is it safe to end a process that is locking a file?

It is safe if you have saved your work in that program and you know what the process is. Ending a process that is actively writing to the file can corrupt it. When in doubt, reboot instead.

Related

Method: the standard formula for this calculation, rounded as each result states. See how the calculators work or report an error.