list of processes running on windows

R

rads

I am new to java, could you please mail me the code, i want the list of
the processes running on windows and from among them, would like to
find for a process say, x.exe and then kill it.
 
M

Mitch

rads said:
I am new to java, could you please mail me the code, i want the list of
the processes running on windows and from among them, would like to
find for a process say, x.exe and then kill it.
ctrl+alt+del
 
J

Joe

rads said:
I am new to java, could you please mail me the code, i want the list of
the processes running on windows and from among them, would like to
find for a process say, x.exe and then kill it.

Take a look at the ProcessBuilder class (assuming you are working with
jdk 1.5+) and the Process class. I could be wrong but programatically
speaking, I think you cannot kill a process that you didnt start
through your program using standard tools. If you are starting your
'x.exe' process from your java program, you can kill it using
Process.destroy().

This is what I do to kill processes that have no affiliation with my
program and it doesnt work in all situations (if someone has a better
solution please let me know):

I'm not sure if you are familiar with cygwin or not but basically its a
set of binaries for windows that provide unix style commands (i'm not
sure what the actual windows commands would be but if there are similar
ones you could use them instead). From my program, I would run the
'ps.exe' binary which lists all curently running processes and parse
the output to find the process id of 'x.exe'. Then, I would run
'kill.exe <process id>'. This is only good if you have only 1 process
named 'x.exe' currently running.

Like I said, if someone else has a better way, please share it because
by no means is this a viable solution for all situations and some OS
knowledge is needed inside the program to keep it platform independent
(i.e. if windows-> do A(), if linux-> do B()).

Again, this solution is shaky at best.

--Joe
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,581
Members
45,056
Latest member
GlycogenSupporthealth

Latest Threads

Top