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?

Widmo
  • 21

3 Answers3

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
johnshen64
  • 6,035
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
MichelZ
  • 11,238
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.

mfinni
  • 36,892