Skip navigation

JSI Tip 3486. How do I close all opened shared files on my 'server'?

If your clients regularly leave shared files open on your 'server', it would be nice to close them all, when needed.

In tip 0678 » The NET FILE command, you learned how to close them one at a time.

NOTE: The NET FILES command only effects files opened from SMB (Server Message Block) clients. Files opened via HTTP, FTP, IPC or RPC are NOT affected. If a client was editing a shared file, closing it will loose the unsaved edits. The Server service must be running for NET FILE to function.

To close all open shared files, run CloseAll.bat, which contains:

@echo off
for /f "Skip=4 tokens=1" %%i in ('NET FILES') do if not "%%i" EQU "The" NET FILE %%i /CLOSE

Hide comments


  • Allowed HTML tags: <em> <strong> <blockquote> <br> <p>

Plain text

  • No HTML tags allowed.
  • Web page addresses and e-mail addresses turn into links automatically.
  • Lines and paragraphs break automatically.