Find Open Files Using Command Prompt Windows 10
You can find open files in Windows 10 using the built-in openfiles command in Command Prompt, which lists files that are currently opened by other users on the system. To use it, open Command Prompt as Administrator and run openfiles /query — this shows local open files, or openfiles /query /fo csv for a more readable format. This article explains the command’s options, how to enable it, common errors, and practical alternatives.
What the openfiles Command Does
The openfiles command is a native Windows tool that displays files opened by network users or, when enabled, files opened locally on the machine. It’s especially useful for IT admins who need to see which files are locked by remote clients before performing maintenance or moving shared folders. The command works on Windows 10 Pro, Enterprise, and Education editions; it is not available on Windows 10 Home.
Key features:
- Query mode – lists current open files with session details.
- Disconnect mode – forcibly closes a specific open file (requires admin rights).
- Enable mode – turns on the tracking of local open files (requires a restart).
How to Enable Local File Tracking
By default, openfiles /query only shows files opened over the network. To see files opened locally (e.g., by a user logged into the same machine), you must enable the “maintain objects list” global flag. This is a one-time step:
- Open Command Prompt as Administrator (right-click Start → “Command Prompt (Admin)”).
- Type
openfiles /local:onand press Enter. - Restart your computer for the change to take effect.
After restart, openfiles /query will include local open files. Note that this setting can also be enabled via Group Policy (Computer Configuration → Administrative Templates → System → File System → “Enable local use of the Openfiles command”).
Using openfiles /query to List Open Files
The basic syntax is:
openfiles /query /fo {TABLE|LIST|CSV} /nh
/fo– sets the output format: TABLE (default), LIST, or CSV./nh– removes the column headers (useful for scripting)./v– shows verbose details like file owner and permissions.
Example: To display open files in a clean CSV format without headers, run:
openfiles /query /fo csv /nh
This outputs lines like: file.exe,username,#session,filepath. The session ID is important if you need to disconnect a file.
How to Disconnect an Open File
If you need to close a specific open file (e.g., to free it for backup), use the disconnect mode:
openfiles /disconnect /id {session_id}
You can find the session ID from the query output. Alternatively, you can disconnect all files for a particular user:
openfiles /disconnect /u username
This forcefully closes the file, so any unsaved work in that file may be lost. Use with caution and only when necessary.
Common Errors and How to Fix Them
“ERROR: The target system must be running a version of Windows that supports this command.” – This occurs when you run openfiles without admin rights or when local tracking is not enabled. Solution: run as Administrator and enable local mode as described above.
“ERROR: The parameter is incorrect.” – Usually means you mistyped a switch. Check the syntax with openfiles /?.
No output at all – If the command returns nothing, it means no files are currently open (or local tracking is off). Try opening a file in another program and re-run the query.
Alternatives to openfiles Command
While openfiles is the only built-in command-line tool, there are other ways to find open files:
- Computer Management – Go to “Shared Folders” → “Open Files” to see a GUI list of open files. This shows the same data as
openfilesbut in a graphical interface. - Resource Monitor – Press Win+R, type
resmon, and go to the “CPU” or “Disk” tab to see which processes have files open. - PowerShell – Use
Get-SmbOpenFileto list open files on SMB shares (more advanced, but gives extra properties).
For local files, third-party tools like Process Explorer can show which process has a file locked, but they are not built into Windows.
Frequently Asked Questions
Why does openfiles show nothing even when I have files open?
Most likely because local tracking is not enabled. Run openfiles /local:on as Administrator and restart. Also, the command only shows files opened by other users, not files opened by the current user in the same session.
Can I use openfiles on Windows 10 Home?
No, the command is only available on Pro, Enterprise, and Education editions. On Home, you can use Computer Management (which also may be limited) or third-party tools.
How do I see which process has a file open?
The openfiles command does not show the process name. Use Resource Monitor or PowerShell’s Get-Process | Where-Object {$_.Path -eq 'filepath'} to find the process.
Will disconnecting a file cause data loss?
Yes, if the user has unsaved changes, they will be lost. Always warn users before disconnecting.
Can I export the list of open files to a text file?
Yes, use the redirection operator: openfiles /query /fo csv > openfiles.csv. This creates a CSV file you can open in Excel.
Related
Method: the standard formula for this calculation, rounded as each result states. See how the calculators work or report an error.