The other option is to use TASK KILL utility which comes with Windows Resurce Kit tool -
Download Link - http://www.dynawell.com/do
Main Topics
Browse All TopicsI have a simple .bat that calls notepad using start:
start notepad
How can I tell what the PID is of the notepad that was started by this, so that I can kill it in the same bat, but not kill another notepad that's running? (I don't want to kill by process name)
This Question has been solved and asker verified All Experts Exchange premium technology solutions are available to subscription members.
Experts Exchange has been collecting answers to technology questions since 1996…3 million and counting! If you have a question, chances are we already have your answer.
If you can't find the exact answer you're looking for, ask our exclusive community of 50,000 experts. You’ll get a personalized answer from a trusted professional.
Thousands of free tech tips, tricks, how-to’s and tutorials are available in our peer reviewed articles section. See for yourself how smart our experts are, no login required.
Access the answers to your technology questions today.
30-day free trial. Register in 60 seconds.
Members of the expert community talk about why the experience at Experts Exchange is different than what you will find anywhere else.

Try it out and discover for yourself.
30-day free trial. Register in 60 seconds.
Join the community of experts here and help other tech pros by answering question in your area of expertise. You can earn FREE access to all Experts Exchange's premium features and resources.
The other option is to use TASK KILL utility which comes with Windows Resurce Kit tool -
Download Link - http://www.dynawell.com/do
To make sure you get really your process, you need to use some tricks. psexec from www.sysinternals.com is needed, and then (showed with cmd, but it does not matter which command you use):
This would work ASSuming no other processes named notepad were started or ended between the time you "start notepad" and when you wanted it killed...
It sums the PID value for all existing notepad processes before the Start Notepad then sums it again after...the difference is the PID of the notepad that was started in this batch...
manav - I am using pstools to start with, so not a problem.
Qlemo - your code looks promising and i'm playing with it since it's the first in the list (and shortest). In playing I couldn't get it to work as written - but did remember that natively psexec returns the PID as the 'errorlevel'
Now I'm just trying to get the real app to run, since it's not notepad, but instead IE calling a specific URL.
This works exactly:
@echo off
psexec -s -d "c:\program files\Internet Explorer\iexplore.exe" http://www.mysite.dom
set pid=%errorlevel%
sleep 10
pskill %pid%
There is something I did not know about PSTools? Didn't think there should come anything anymore ;-). For the files:
Business Accounts
Answer for Membership
by: manav08Posted on 2009-09-09 at 08:34:40ID: 25292368
Unfortunately what you are trying to achieve is possible but only by using PSTOOLs. om/en-us/s ysinternal s/ bb896682 .aspx om/en-us/s ysinternal s/ bb896683 .aspx
Just bare in mind that everytime a NOTEPAD is launched the processid will be different. I am not sure what you are trying to achieve but the process-id will vary everytime the notepad applications is launched.
2 Tools to find out Process List and then kill them are -
http://technet.microsoft.c
http://technet.microsoft.c