Server Fault is a question and answer site for system and network administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

How do I kill all program.exe instances that are currently open through a Windows network share?

I know how to list the open files net files | Findstr "program.exe" but how then how do I kill it?

In Linux I would type:

kill -9 `pidof program.exe`

What is the equivalent of this in Windows?

share|improve this question
Windows Samba ? ... – Gregory MOUSSAT May 21 '12 at 20:58
Windows Share ( SMB ) – Widmo May 21 '12 at 21:03
net files shows you files that are open on your machine from other peoples computers. Do you want to kill the process on the remote machine? If so, then we'll need to know what versions of Windows they're running. – Mark Henderson May 22 '12 at 3:55

If your windows version has powershell (if not, you can download and install from microsoft site), it is very easy as well

get-process "program.exe" | stop-process -force -confirm:$false
share|improve this answer
You writing about system processes, but i'm looking for open network files ( look at: net files ) :) – Widmo May 21 '12 at 21:22
oh sorry i thought you were asking for processes. net file filenum /close is what you are looking for then? where filenum is what you find in the net files listing. – johnshen64 May 21 '12 at 21:31
True, net file /close is what i am looking for, i wrote it in 1st post ;) But i don't know how to connect it with findstring and kill PID's only from program: sample.exe ;) So: I need to do one command and kill all PID's from files example.exe :) – Widmo May 21 '12 at 21:44
i don't think there is a such a command, but there might be batch files or powershells scripts available, or you can write one. if you have powershell, i can likely whip up one for you quickly if you cannot write one quickly and cannot find one written by someone else, but not batch file, as i am really rusty in batch files by now :-) – johnshen64 May 21 '12 at 21:50

Look here:

I believe this still applies to current Windows versions, or should at least put you in the right direction.

Command line:

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

Batch file:

for /f "skip=4 tokens=1" %%a in ('net files') do net files %%a /close
share|improve this answer

tskill.exe (either built-in or possibly in a resource kit) or pskill.exe, from sysinternals - which as a Windows admin, you should have on a USB key and on a network share.

Also, don't forget to include which version of Windows you're working on - that may make a difference with someone's answer - although likely not for this question.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.