I'm looking for a solution to a problem that I'm having involving some batch
files. There is a custom java application which we run at work under
Windows 2000 which launches 2 batch files when the program is executed. Now
for one reason or another, I need to kill one of those batch file processes
a few minutes after starting this application.
When I bring up the task manager, I see the name of all running
applications including my 2 batch files (which have different names) and
when I click on the Proceses tab, I see 2 instances of CMD.EXE with
different process ID's. These process ID's are different everytime the
application/batch files are launched. I can easily use the "kill.exe"
utility from the NT/Win2K resource kit to kill the process ID # of the batch
file I want to close but since process ID's change all the time, I can't use
a kill.exe in a batch file. And if I try and kill CMD.exe, it closes all
command prompt windows.
My question is, is there a way (or program) which can close one of my batch
files via a command prompt by using its application name? The file appears
as "batch1.bat" under applications in task manager but the command "kill
batch1.bat" does not work as you can only kill an application by its process
name or ID and not by its application name.
Any help would be appreciated!
Michel
Add a 'title' command to the batch file so that you can identify it in tlist:
:
:
:
226 MsgSys.EXE
171 ClipMt53.exe ClipMate [========begin file C:\CMD\TEST\REDATE.CMD====]
108 netscape.exe Question - Killing an application from a Command Prompt window?
213 ntvdm.exe Wylbur/AT
258 CMD.EXE NT4.0 CMD - tlist
283 CMD.EXE "mytest batch file" <<<<--------
240 Sleep.exe
272 TLIST.EXE
Then get its process id by
@echo off
for /f "tokens=1" %%a in (
'tlist ^| findstr /c:"mytest batch file"'
) do set PID=%%a
if defined PID kill %PID%
Hope this helps.
Phil Robyn
Univ. of California, Berkeley
--
u n z i p m y a d d r e s s t o s e n d e - m a i l
"Phil Robyn" <pro...@uclink.berkzipeley.edu> wrote in message
news:3BF5EE61...@uclink.berkzipeley.edu...
Yes, that's true, but unfortunately in this case the batch file
is not running as a service....