2

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?

3
  • Windows Samba ? ... May 21, 2012 at 20:58
  • Windows Share ( SMB )
    – Widmo
    May 21, 2012 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. May 22, 2012 at 3:55

3 Answers 3

2

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
4
  • You writing about system processes, but i'm looking for open network files ( look at: net files ) :)
    – Widmo
    May 21, 2012 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, 2012 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, 2012 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, 2012 at 21:50
1

Look here: http://support.microsoft.com/kb/290585/en-us

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
0

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.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .