What I am trying to do it is a program to know if a process it is active on Windows
to work with it in Java
. I looked on the Internet and found two different solutions:
But it is not at all what I am looking for.
According to the option 1, I would like a method to make reference to the process (and detect if it is active/running) but without searching in the full tasklist
and then searching on it. I am searching if there is a direct method to do that.
I also though to add a filter to the tasklist but could not find any filter to only get the process I am looking for. I saw all the options using tasklist /?
on my command line.
Then I searched information about the second option and wmic
(that I never heard before) and it seems that wmic
allows you to execute tasks on the command line (correct me if I am wrong please).
So, here I have two questions:
Is there a direct method to know if a process is active on Windows with Java? Trying to avoid searching in the full tasklist or using
wmic
.If it is impossible, what of the two options that I put above would be better if we talk about efficient programming?
Thanks in advance!