I am writing using JavaScript. I have a PID of a process. How do I kill it?
You can terminate by a name using WMI, How can you do it using PID?
UPDATE: The platform is Windows.
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
It looks like you’re coding for either Windows Script Host or a Windows Desktop Gadget. If it is, I would use
WScript.Shelland itsExecmethod along with the command line taskkill (Win XP Pro, Win Vista & Win 7 only):If you really want to do it with WMI something like the following works fine for me (thanks @Helen for the improvements):