I am starting a notepad from command prompt using the command:

start notepad

I am not aware of the PID of this instance of notepad. In such a case, how can I close the same instance of notepad using some other commands in command prompt?

Please advice


Source TASKKILL - End one or more processes (by process id or image name).


TASKKILL [/S system [/U username [/P [password]]]] { [/FI filter] [/PID processid | /IM imagename] } [/F] [/T]


Filters Apply one of the Filters below:

  • Imagename eq, ne String
  • PID eq, ne, gt, lt, ge, le Positive integer.
  • Session eq, ne, gt, lt, ge, le Any valid session number.
  • Status eq, ne RUNNING | NOT RESPONDING
  • CPUTime eq, ne, gt, lt, ge, le Time hh:mm:ss
  • MemUsage eq, ne, gt, lt, ge, le Any valid integer.
  • Username eq, ne User name ([Domain]User).
  • Services eq, ne String The service name
  • Windowtitle eq, ne String
  • Modules eq, ne String The DLL name

You need to use a command like the following:

TASKKILL /F /FI "WINDOWTITLE eq NotepadWindowTitle"
  • This did not work for me....:-( – Prasanna Oct 18 '14 at 18:13

taskkill /im notepad.exe /f

more about taskkill here.

If you have more than one notepad.exe open, you can use tasklist to get the PID.

  • This is fine. But in some cases, when I run a couple of Java Based desktop application, both the names comes as java.exe. In such a scenario, if I need to close one of them then how can I understand which java.exe represents which java application? please suggest – user182944 Oct 18 '14 at 17:21
  • ya thats fine but how will I understand which notepad is the first instance and which one is the second? – user182944 Oct 18 '14 at 17:23
  • 1
    taskkill can use window title, assuming the window has a title. – Keltari Oct 18 '14 at 17:24
  • The window I have does have a title and this is something I was looking for. Please let me know how will the command taskkill be used for closing a window with title: demo ? – user182944 Oct 18 '14 at 17:26

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.