3
I have portable version of an app. I have ran for example 5 multiple instances of it and they all have the same process name but different pids. I want to find a way to for example kill one specific process, cause using taskkill with the name of that process would kill all of those. I want to kill just the specific one by providing the pid of that process.
Now the question is: How can I find a process pid so that I can use this number to kill that specific application easily?
For example I want to kill the third one (I mean by using time).
Can pid gives me information of when a process was ran? If not What are the other workarounds?
That is not possible under windows (and i don't think its possible under linux and unix either), but you can get and kill windows filtering by process name, main window handler, window class and some other methods. – Felype – 2015-04-25T21:14:33.660
1You are asking the wrong question. Since the instances already have different PIDs (as you've yourself stated), there's no need to change these PIDs when you just want to kill certain instances. See my answer below. – Karan – 2015-04-25T21:18:20.847
@Karan Lets make this interesting. Assume I want to do this from a batch file (automate things and schedule them) and I dont know what is the pid of that process (and again there are multiple instances with same names). – None – 2015-04-26T21:26:58.030
2Perhaps the question you should be asking is "When I start an application (e.g., from a batch file), how can the batch script *learn* the PID of the application process, so it can use it later to kill the process?" (The answer might be: run
tasklist
with output to a file before and after starting the application, then compare the output files to see what PID is in the second file but not the first.) Or perhaps, "Given multiple Windows processes, how can I distinguish among them (e.g., by start time or other discriminators)?" – Scott – 2015-04-27T04:11:47.703Also, (1) You might want to tag your question with [windows] (ideally, specifying the exact version that you're using) and [batch], because, until you edited the question, there was no way to tell that you weren't talking about Unix. Also, (2) I don't understand what you mean by "I have an application installed on my computer ... and I have the portable version of that too." If that's important to your question, you might want to reword it. – Scott – 2015-04-27T04:12:57.533
@MrKlKl: Here you go, see the batch file in my edited answer below. Also as Scott mentioned above you really should edit the question title, tags and probably the body as well to remove all references to setting PIDs. – Karan – 2015-04-27T05:00:17.227
Ok @Scott By Installation I meant that the application leaves traces (registery etc.) which the portable dont. I thought this make a difference between installed and portable processes of an application. which now I think dont. – None – 2015-04-29T07:30:27.343