OPENFILES

Lists or disconnects open files and directories on a specified system.

OPENFILES /parameter [arguments]

Where, instead of parameter:

  • /DISCONNECT - Disconnects one or more open files.
  • /QUERY - Displays files opened locally or in shared directories.
  • /LOCAL - Enables or disables tracking of files opened locally.

Syntax for disconnecting open files and directories from remote workstations via a shared directory:

OPENFILES /DISCONNECT [/S system [/U username [/P [password]]]] {[/ID id] | [/A username2] | [/O access_mode]} [/OP open_file] [/?]

Where:

  • /S system - Specifies the remote system to connect to. If not specified, the local system is used.
  • /U username - Specifies the user to connect as. If needed, specify the domain in the format domain\username.
  • /P [password] - Specifies the password for username. If not provided, the user will be prompted.
  • /ID id - Specifies the ID of the file to disconnect. Use the wildcard character * to disconnect all files regardless of ID.
  • /A username2 - Specifies the user associated with the files to disconnect. Use * to disconnect files from all users.
  • /O access_mode - Specifies the access mode of the files to disconnect. Use READ, WRITE, READ/WRITE, or * to match all modes.
  • /OP open_file - Specifies the name of the open file to disconnect. Use * to disconnect all files regardless of name.
  • /? - Displays help for the OPENFILES /DISCONNECT command.

Examples:

1. Disconnects files associated with user donalduck123 opened in read/write mode:

openfiles /disconnect /a donalduck123 /o read/write

2. Disconnects all files by ID for user luser with password passwrod on remote computer myneighbor:

openfiles /disconnect /s myneighbor /u luser /p passwrod /id *

3. Disconnects the open file C:\beef_fillets.txt with ID 10:

openfiles /disconnect /op C:\beef_fillets.txt /id 10

Syntax for viewing open files and directories from remote workstations:

OPENFILES /QUERY [/S system [/U username [/P [password]]]] [/FO format] [/NH] [/V] [/?]

Where:

  • /S system - Specifies the remote system to connect to. Defaults to the local system if omitted.
  • /U username - Specifies the user whose open files to view. Include domain if needed: domain\username.
  • /P [password] - Specifies the password for username. If omitted, it will be requested.
  • /FO format - Specifies the output format:
    • TABLE - table format
    • LIST - list format
    • CSV - comma-separated values
  • /NH - Omits headers in the output. Only valid with TABLE and CSV formats.
  • /V - Enables verbose (detailed) mode.
  • /? - Displays help for the OPENFILES /QUERY command.

Examples:

1. Verbosely lists all open files for the current user in list format:

openfiles /query /fo list /v

2. Lists all open files for user luser with password passwrod on remote computer myneighbor in table format without headers:

openfiles /query /s myneighbor /u luser /p passwrod /fo table /nh

Syntax for enabling or disabling local file handle tracking:

OPENFILES /LOCAL [ON | OFF | /?]

Where:

  • ON - Enables local file handle tracking.
  • OFF - Disables local file handle tracking.
  • /? - Displays help for the OPENFILES /LOCAL command.

Changes made with this command take effect only after a system restart. By default, this setting is disabled.

Example: Enable local file handle tracking:

openfiles /local on

Comments