Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsWhite Papers
Discussion GroupsFirst AidDatabasesJavaBeansGUIJava 3DVirtual MachineCORBASecurityToolsGeneral
Java DirectoryOpen Source ProjectsSample Book ChaptersUser GroupsWeb Resources
Related Topics
Databases.NETMore Topics ...

Java Forum / General / May 2006

Tip: Looking for answers? Try searching our database.

list of processes running on windows

Thread view: 
rads - 22 May 2006 11:11 GMT
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.
Mitch - 22 May 2006 13:06 GMT
> 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
Joe - 22 May 2006 13:43 GMT
> 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


Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.