The OPENFILES command in Windows Command Prompt is a utility used to display or disconnect open files and folders on a system. It helps system administrators manage file sharing by showing which files are in use and by whom. This is particularly useful in environments where files are shared across a network, allowing the administrator to prevent data corruption or unauthorized access by managing file usage directly.


The basic syntax for OPENFILES is:

OPENFILES /query [/s Computer [/u Domain\User [/p Password]]] [/fo {TABLE|LIST|CSV}] [/nh] [/v]
OPENFILES /disconnect [/s Computer [/u Domain\User [/p Password]]] [/id {<Id>|*}] [/a {<Accessed_by>|*}] [/o {<Open_file>|*}]


  • /query : Display the list of open files.
  • /disconnect : Disconnect open files.

Common Parameters for Both Modes:

  • /s Computer : Specifies the remote computer to connect to.
  • /u Domain\User : Specifies the user context under which the command should execute.
  • /p Password : Specifies the password for the given user context. Prompt for input if omitted.
  • /fo {TABLE|LIST|CSV} : Specifies the format in which the output is to be displayed.
  • /nh : Suppresses column headers in the output. Useful for scripting.
  • /v : Specifies that the detailed information should be displayed.


  • /query : Lists all open files. Works locally unless combined with /s to specify a different computer.
  • /disconnect : Allows the administrator to disconnect open files. Use with caution as it can cause data loss if files are in use.

Query-specific Flags

  • /fo : Format options include TABLE, LIST, or CSV. Default is TABLE.
  • /nh : When used, the output will not include column headers, making it easier to parse programmatically.
  • /v : Enables verbose mode, showing more detailed information about each file.

Disconnect-specific Flags

  • /id <Id> : Disconnect files by their unique identifier.
  • /a <Accessed_by> : Disconnect all files accessed by a specific user.
  • /o <Open_file> : Disconnect files by file path.


Querying Open Files

Display all open files in table format:


Display open files in CSV format, no headers:

OPENFILES /query /fo CSV /nh

Disconnecting Open Files

Disconnect all files opened by the user admin:

OPENFILES /disconnect /a admin

Disconnect a specific file by ID:

OPENFILES /disconnect /id 1234

Common Issues

  • Access Denied: Without proper permissions, OPENFILES may return an access denied error. Ensure you have the required administrative privileges.
  • Network Delays: When querying or disconnecting files over a network, the command might take longer to execute due to network latency.


OPENFILES can be integrated into scripts that monitor and manage file usage to maintain network health. Here’s an example that combines TASKLIST and OPENFILES to monitor resource usage:

OPENFILES /query /fo CSV | FINDSTR /i "myfile.txt"
TASKLIST /fi "IMAGENAME eq notepad.exe"

This script checks if “myfile.txt” is open and lists all instances of notepad.exe running on the computer.

  • NET FILE: Similar functionality for managing file sharing.
  • TASKLIST: Displays a list of currently running processes.

For detailed documentation, you can visit the official Microsoft documentation for OPENFILES.