• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 582
  • Last Modified:

cmd line command to kill open files on a server?

Is there some command line command to kill all connections to an open file on a server?

myfootsmells
0
myfootsmells
Asked:
myfootsmells
  • 3
1 Solution
 
Lee W, MVPTechnology and Business Process AdvisorCommented:
Well:
net stop server
will stop the server serrvice and cut off everyone connected.

A quick way to do this is to type the following on a command line:

net stop server & net start server

The above line will both stop and then restart the server service in as quick a time as possible.

You do realize, you'll end up potentially screwing up peoples files if you close open connections...
0
 
myfootsmellsAuthor Commented:
There isn't a way for me to close a specific file?

Yes I understand that, but there are certain files that need to be altered at midnight and if users have that file open, well it doesnt work :)

myfootsmells
0
 
Lee W, MVPTechnology and Business Process AdvisorCommented:
0
 
Lee W, MVPTechnology and Business Process AdvisorCommented:
And lastly, this may be exactly what you are looking for:

for /f "usebackq tokens=1" %a in (`net file ^| find /i "OpenFileName"`) do @net file %a /close

Note: if using this in a batch file, replace all %a with %%a - the above entry is meant only for running directly from a command line.
0

Featured Post

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

  • 3
Tackle projects and never again get stuck behind a technical roadblock.
Join Now