See Which Shared Files Are Open on Your PC (and Disconnect Them)

List every file that other computers on the network have opened on your shared folders with openfiles /query, and cut a session with /disconnect.

WindowsFilescmdsecurityMedium risk
Run `openfiles /query /fo table` in an administrator terminal to list remotely opened files, then `openfiles /disconnect /id <ID>` to close one.

01Command

Command
$ openfiles /query /fo table
# disconnect a specific open file by ID:
openfiles /disconnect /id 1234

02What it does

If you share folders on a home or office network, other people may hold files open without you knowing — which is why a file sometimes refuses to move or delete. Windows can track these objects, and the openfiles command reports them: /query lists each remotely opened file with its access mode and an ID number. Before the list shows anything, tracking must be enabled once with openfiles /local on plus a reboot; afterwards you can also forcibly close a file with /disconnect.

03Risk

RiskMedium risk
RequirementsRequires an administrator terminal. You must first run `openfiles /local on` and reboot once so Windows tracks locally opened files.
!Warning: Disconnecting a remote user mid-write can leave their copy of the document half-saved — give colleagues a heads-up before pulling the plug.

04Undo

✓No undo needed — this command does not change persistent state.

05Sources

Last verified: 2026-09-19 · Category: Files & Folders

06Related solutions