• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 592
  • 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
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Cloud Class® Course: CompTIA Healthcare IT Tech

This course will help prep you to earn the CompTIA Healthcare IT Technician certification showing that you have the knowledge and skills needed to succeed in installing, managing, and troubleshooting IT systems in medical and clinical settings.

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