stopping a .bat script

D

Dietmar Hochsteing

Hi guys,

I've written a small batch script which itself calls Windows Scripting
Host (cscript.exe), the purpose being that a remote webcam start
broadcasting images. It all works well, but I'd like to be able to
cancel this broadcasting script via another script, as I am actually
connected to the host computer via ssh. In Unix, it'd be easy, a simple
pipe "ps x | grep <scriptname> | kill" would get the process ID and
kill it, but there is no such things on Windows. So does anyone know a
scriptable way to stop another running script?

Thanks

Dietmar
 
Joined
Sep 27, 2005
Messages
1
Reaction score
0
Sysinternals Pskill

There is an application for the Windows environment that can operate in a similar fashion to the GREP process upon a Unix box.

The application combination I use for preference is from SysInternals, called PSLIST and PSKILL.

This allows a number of options, including:

Kill process by Process ID i.e. 1024, 7876, 546, etc.
Kill process by Process Name i.e iexplore, winword, excel, etc.

The only word of warning is that is kills all process that match the specified name, so multiple copies of Microsoft Word that are running will all be terminated if you use a command such as PSKILL WINWORD.

So you could use something like this, if you want control over the termination of multiple processes at the same time:

for /f "tokens=1 delims=," %%i in ('pslist ') do (
for /f "tokens=1,2,3*" %%y in ("%%i") do (
if "%%y"=="KILL_THIS_NAMED_PROCESS" pskill %%y
if "%%y"=="KILL_THIS_NAMED_PROCESS_2" pskill %%y
)
)

or

pskill KILL_THIS_NAMED_PROCESS

or

pskill KILL_THIS_PROCESS_ID

Joe.
 
Last edited:

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top