ContextCleaner: see every entry in the Windows 11 right-click menu, and which app added it — on the Microsoft Store.
Windows Tips & Tools LockGhost

How to Use the openfiles Command to See Which Files Are Open on Windows (and When It Won't Help)

Published October 20, 2026 Updated October 23, 2026 8 min read

openfiles is a built-in Windows command that lists files and folders that are open on a system, and it can disconnect files that other people have open over a shared folder. For files opened by programs on your own PC, it shows nothing useful until an administrator runs openfiles /local on and restarts Windows, and Microsoft warns that the setting might slow the system down. If you just need to know what is holding one file right now, LockGhost from Automata Labs answers that without a restart: right-click the path and it names every process using it through the Windows Restart Manager API.

See which app is holding a file right now, without a restart or a global flag.

Get it from Microsoft

What does the openfiles command do?

Microsoft’s openfiles reference describes it as a command that “enables an administrator to query, display, or disconnect files and directories that have been opened on a system.” It applies to Windows 10 and Windows 11 as well as Windows Server, and it has three parts:

CommandWhat it doesTypical use
openfiles /queryLists open files, as a table, list or CSVSee what is open, locally or on a file server
openfiles /disconnectCloses files that were opened remotely through a shared folderFree a file someone left open on a share
openfiles /localShows or changes the Maintain Objects List global flagMake local file handles visible to /query

You run it from an elevated Command Prompt or PowerShell window. The command is aimed at administrators, and most of its options (/s, /u, /p) are about querying another computer with different credentials.

Why does openfiles /query not show my local files?

This is the part most guides skip. By default, Windows does not keep the list that openfiles needs to report files opened by local programs. That list is controlled by a system-wide setting called the Maintain Objects List global flag.

From Microsoft’s documentation:

  • openfiles /local with no parameters shows the current state of the flag.
  • By default the flag is disabled, and the command reports: “INFO: The system global flag ‘maintain objects list’ is currently disabled.”
  • openfiles /local on enables it, with the message “This will take effect after the system is restarted.”
  • Microsoft notes that changes “don’t take effect until you restart the system” and that enabling the flag “might slow down your system.”

So the honest answer to “how do I see which program has my file open with openfiles” is: turn on a global flag, restart, then query. That is a reasonable thing to do on a test machine or a server you are diagnosing over a few days. It is a heavy step for one stuck file on a laptop, because the restart itself closes the handle you were trying to find.

How do I use openfiles step by step?

If you do want to use it, here is the sequence, using only the commands documented by Microsoft.

  1. Open an elevated terminal. Right-click Windows Terminal or Command Prompt and choose Run as administrator.
  2. Check the flag. Run openfiles /local. If it says the flag is disabled, local files will not be listed yet.
  3. Enable local tracking if you need it. Run openfiles /local on, then restart Windows.
  4. Query open files. Run openfiles /query. For more detail, use openfiles /query /fo list /v.
  5. Export the list if it is long. openfiles /query /fo csv /v > open-files.csv gives you a CSV you can filter.
  6. Disconnect remote opens if that is the problem. On a file server, openfiles /disconnect /id <ID> closes one file using the ID from /query, and openfiles /disconnect /a <user> closes everything a given user has open.
  7. Turn the flag off when you are done. Run openfiles /local off and restart, so the system is back to its default.

Note that /disconnect is documented for files and folders “opened remotely through a shared folder.” It is not a way to force a local program to let go of a file on your own PC.

Is openfiles the right tool for “file in use” errors?

It depends on where the file is open from.

SituationGood toolWhy
Users have files open on a file share you manageopenfiles /query and /disconnectThis is what the command was built for, and it works without the local flag
You want an audit of local open files over time on a test machineopenfiles /local on, restart, then /queryAccepts the restart and the possible slowdown
One file or folder on your PC will not delete, rename or saveLockGhostAnswers the question now, by friendly process name, no restart
You need every handle a process holds, from a scriptSysinternals HandleCommand-line handle listing, requires admin

Microsoft’s own Sysinternals Handle utility is the other command-line option. Its documentation says it “displays information about open handles for any process in the system,” that you “can use it to see the programs that have a file open,” and that you “must have administrative privilege to run Handle.” It is a separate download, and its output is a raw list you then interpret yourself. We compare that route in more detail in how to find the handle holding a file without Process Explorer.

How does LockGhost find the process without a restart?

Windows already has a supported way to ask “which applications are using this file?” without any global flag. It is the Restart Manager, the API installers use to find out which applications and services are holding files they need to replace. Because it is designed for that question, it works on a normal PC in its normal state.

LockGhost is built on that API. According to its product page and Microsoft Store listing:

  • One field, three ways in. Paste a path, drag a file or folder in, or right-click it in File Explorer.
  • Every process holding the path, shown by friendly name rather than a bare process ID.
  • Color-coded severity, so a system process stands out from an app you can safely close.
  • Guarded End Process. LockGhost confirms before ending a process and blocks critical system roles.
  • Local lock history stored on your PC, so you can see what held a file last time.
  • Offline, with no account and no telemetry.

There is a short explainer on the API itself in the Restart Manager way to find a file lock.

Right-click the stuck file and get the process name, not a reboot.

Get it from Microsoft

openfiles vs LockGhost at a glance

openfilesLockGhost
Built into WindowsYesNo, one-time purchase
Shows local open files by defaultNo, needs /local on and a restartYes
May slow the systemMicrosoft says enabling the flag mightNo global flag is changed
Shows files open on a shareYes, and can disconnect themFocused on local locks
Works from Explorer right-clickNoYes
Friendly names and severityNoYes
ExportTable, list or CSVLocal lock history
Needs an elevated terminalYesNo terminal at all

If you run a file server, keep openfiles in your toolkit. It is the right way to see and close files that users hold open on a share. For the everyday “the action can’t be completed because the file is open in another program” message on your own PC, a tool that asks Restart Manager is faster and leaves your system settings alone.

What should I check before ending the process?

Whichever tool names the culprit, take a second before you end anything:

  1. Close the file in the app first. Saving and closing the document is always safer than ending the process.
  2. Check whether it is a sync client or antivirus. Those often release the file on their own within seconds.
  3. Avoid ending system processes. Ending Explorer or a Windows service can lose work or destabilize the session.
  4. Retry the action. Delete, rename or save again once the handle is closed.

For common cases, see cannot delete a file in use and cannot delete a folder in use on Windows 11.

Frequently asked questions

Does openfiles work on Windows 11?

Yes. Microsoft lists Windows 11 and Windows 10 among the systems the command applies to. You need an elevated terminal.

Why does openfiles say the maintain objects list is disabled?

That is the default. Windows does not track local file handles for openfiles unless an administrator runs openfiles /local on and restarts.

Can openfiles close a file a program has open on my PC?

No. openfiles /disconnect is documented for files opened remotely through a shared folder. For a local lock, close the program that holds the file.

Is it safe to leave the maintain objects list on?

Microsoft warns that enabling it might slow down your system. Turn it off with openfiles /local off and restart when you are done.

What is the fastest way to see what is locking one file?

Use a tool built on the Restart Manager API, such as LockGhost. It answers immediately, with no restart or global flag.

Try LockGhost

Get LockGhost from the Microsoft Store. It is a one-time purchase with no subscription, and the Store listing shows the current price.

Find what is holding your file in one right-click, then finish the job.

Get it from Microsoft

Microsoft, Windows, Windows Server, Sysinternals and File Explorer are trademarks of the Microsoft group of companies. LockGhost is not affiliated with or endorsed by Microsoft.

Last updated 20 October 2026. Published by Automata Labs, a software company in Canada.

// release_radar

Get notified about new releases.

We build native, local-first tools for professionals who refuse SaaS fatigue. Drop your email to hear about new apps, major updates, and zero-telemetry releases as they land on the Microsoft Store. No spam — just release news.