Super User is a question and answer site for computer enthusiasts and power users. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I have a Windows 7 computer that is hosting some files in my network. Sometimes a file (usually an Office document) is stuck in the open state even after a user has finished editing it. What I do to resolve this is to go to Computer Management > Shared Folders > Open Files and close the connection to the culprit file.

However, I always have to do this by remote controlling the host computer. Is there a faster way to accomplish this? I'm open to anything that can help me speed up the process (batch, powershell, remote MMC, etc).

What I've Tried:

I've tried using Remote MMC from my workstation into the host, but when I try to open System Tools > Shared Folders > Open Files I get error You do not have permissions to see the list of files opened by Windows clients.


While remote commands are great, and I'd be open to using them, I need a way to both list the files, identify which one I need closed, and close it in relatively the same amount of time that it would take to use the MMC snap-in to do it through the GUI.

share|improve this question
check out my comment on Keltari's answer. Net file is your friend. ;) – Ƭᴇcʜιᴇ007 Sep 11 '13 at 16:00
up vote 4 down vote accepted

From this TechNet article :

To close an open shared file or folder by using the Windows interface:

  1. Open Computer Management.
  2. If the User Account Control dialog box appears, confirm that the action it displays is what you want, and then click Yes.
  3. Go under the Action menu and click Connect to another computer . . .
  4. In the console tree, click System Tools, click Shared Folders, and then click Open Files.
  5. Do one of the following:
  6. To close all open files and folders, on the Action menu, click Disconnect All Open Files.

  7. To close a specific file or folder, in the Results pane right-click the file or folder name, and then click Close Open File.

  8. To disconnect multiple open files or folders, press the CTRL key while clicking the file or folder names, right-click any one of the selected files or folders, and then click Close Open File. This closes the selected files or folders.

To close an open shared file or folder by using a command line

  1. To open an elevated Command Prompt window, click Start, point to All Programs, click Accessories, right-click Command Prompt, and then click Run as administrator.
  2. If the User Account Control dialog box appears, confirm that the action it displays is what you want, and then click Yes.
  3. Type:

net file <ID> /close

For example, to close an open file identified as myfile_id, type:

net file myfile_id /close

share|improve this answer
Thanks, but I'm trying to do this remotely from another workstation. The net file command would be useful, but without the file IDs on hand, it would be tough to put it into practice. – Moses Sep 11 '13 at 15:50
you can always use psexec to issue remote commands – Keltari Sep 11 '13 at 15:51
I know how to execute a command remotely, but without the list of files, how am I going to execute the remote command to successfully close one? – Moses Sep 11 '13 at 15:53
net file without any arguments lists the open files and their IDs. So you could use PSExec to run Net File to get a list on the remote computer, and then use it again with Net File <id> /Close. Or perhaps just use PSFile, since it can work with remote computers inherently. – Ƭᴇcʜιᴇ007 Sep 11 '13 at 15:58
@techie007 I just discovered that, thank you! Added my own answer to combine both commands. – Moses Sep 11 '13 at 16:03

I was able to get a viable solution after expanding on the bottom section of Keltari's answer.

I can execute net file <ID> /close to terminate a connection to a file, but without a list of files that are currently open, the command is useless.

By simply executing net file, it will print a list similar to what is listed in the GUI for the MMC Shared Files Snap-in. It lists the File ID, File Path, Username, and # of locks on the file.

Using this information I can follow up with the net file <ID> /close command to close the file.

To do this remotely, I can use Psexec as Keltari suggested. Or PsFile as suggested by the venerable techie007 :)

Alternative solution:

I found a lovely little piece of freeware called ShareWatch that can remotely view shares. This is a nice little tool as it lists not only the user and the file they have open, but the IP of that user as well. You can also remotely close shares.

share|improve this answer
To reiterate - if you're going to be getting PSExec involved, just use PSFile instead - reduce a couple steps. :) – Ƭᴇcʜιᴇ007 Sep 11 '13 at 16:27
@techie007 Thanks, I read too fast :) – Moses Sep 12 '13 at 17:17

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .