Solved

cmd line command to kill open files on a server?

Posted on 2004-09-22
5
561 Views
Last Modified: 2008-01-16
Is there some command line command to kill all connections to an open file on a server?

myfootsmells
0
Comment
Question by:myfootsmells
  • 3
5 Comments
 
LVL 95

Expert Comment

by:Lee W, MVP
ID: 12124948
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
 
LVL 5

Author Comment

by:myfootsmells
ID: 12125188
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
 
LVL 95

Expert Comment

by:Lee W, MVP
ID: 12125316
0
 
LVL 95

Accepted Solution

by:
Lee W, MVP earned 50 total points
ID: 12125335
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
 
LVL 5

Expert Comment

by:sai2480
ID: 12131778
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Hello I read in a discussion about a person who configured a very simple mirror RAID with two hard drives; the system and data were on the same partition. He asked how to repair the system as it was not booting up anymore. In his case running …
I use more than 1 computer in my office for various reasons. Multiple keyboards and mice take up more than just extra space, they make working a little more complicated. Using one mouse and keyboard for all of my computers makes life easier. This co…
This is used to tweak the memory usage for your computer, it is used for servers more so than workstations but just be careful editing registry settings as it may cause irreversible results. I hold no responsibility for anything you do to the regist…
Hi friends,  in this video  I'll show you how new windows 10 user can learn the using of windows 10. Thank you.

895 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

16 Experts available now in Live!

Get 1:1 Help Now