Windows Server 2003 in a Nutshell

openfiles new in WS2003

Displays or disconnects files opened by local or network users.

Syntax

openfiles / command switches

Options

command

Specifies the action to perform, which can be:

query

Displays all open files

disconnect

Disconnects one or more open files

The full syntax for these two commands is:

/query [/s Computer [/u Domain \ User [/p Password ]]] [/fo {TABLE LIST CSV}] [/nh] [/v]

and:

/disconnect [/s Computer [/u Domain \ User [/p Password ]]] {[/id OpenFileID ] [/a UserName ] [/o OpenMode ]} [/op OpenFileName ]

The various switches are:

/s Computer /u [Domain\]User /p [Password]

Name or IP address of a remote computer (if omitted, defaults to local computer) and credentials for running the script (if omitted, defaults to System built-in identity).

/fo {TABLE LIST CSV}

Format for displaying driver properties (if omitted, default is TABLE ).

/nh

Omits header row from displayed information if /fo is set to TABLE or CSV .

/v

Displays verbose information.

/id OpenFileID

Disconnects an open file with a specific numeric ID (use openfiles /query to find the ID). A wildcard (*) can also be used to disconnect all open files.

/a UserName

Disconnects all open files for a specific user. A wildcard (*) can also be used.

/o OpenMode

Disconnects all open files by OpenMode value (Read, Write or Read/Write). A wildcard (*) can also be used.

/op OpenFileName

Disconnects all open file connections created by a specific OpenFile name. The wildcard (*) disconnects all open files on the specified computer.

Examples

List open files on member server with IP address 172.16.11.230:

openfiles /query /s 172.16.11.230 /fo list ID: 41 Accessed By: ADMINISTRATOR Type: Windows Open File (Path\executable): C:\caps ID: 104 Accessed By: ADMINISTRATOR Type: Windows Open File (Path\executable): \PIPE\srvsvc

Disconnect open file with ID 41:

openfiles /disconnect /s 172.16.11.230 /id 41 SUCCESS: The connection to the open file "C:\caps" has been terminated.

Verify the result (verbose mode):

openfiles /query /s 172.16.11.230 /fo list /v Hostname: ESRV230D ID: 111 Accessed By: ADMINISTRATOR Type: Windows #Locks: 0 Open Mode: Write + Read Open File (Path\executable): \PIPE\srvsvc

See Also

Files and Folders

Категории