Tip
Subject Content

129
Close all files from the command line in Windows 2000 Server

Maintaining busy servers is far from easy. You not only have to keep them up and running, but you

also have to make sure the resources are available to users. However, there are times when you'll

want to close those resources--such as before doing a maintenance backup or other activity that

requires exclusive access to resources.



Several UI tools will close opened files. To use Computer Management to close open files, run the

management console and expand System Tools | Shared Folders | Open Files. Then, right-click an

individual file to close the file, or right-click the Open Files node to close them all at once.



You can automate this process by using a command line. Typing the following command will close

all files opened by network clients:



for /f "skip=4 tokens=1" %a in ('net files') do net files %a /close



This command executes the net files /close command on all files from the net files list. Because the

last entry on the net files list is not a file, you'll get an error message even though all files were

closed.



If you want to use net files in a batch file, you have to use a slightly different syntax:



for /f "skip=4 tokens=1" %%a in ('net files') do net files %%a /close

Page 129 of 237
First Previous Next Last