wood burning stoves 2.0*
The moose likes Beginning Java and the fly likes How to kill a windows process using java? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "How to kill a windows process using java?" Watch "How to kill a windows process using java?" New topic
Author

How to kill a windows process using java?

Jon Lee
Ranch Hand

Joined: Mar 04, 2005
Posts: 134
On windows platform, how to use java code to kill a process?? For example, I start a process called flashfxp.exe, can I use java code to kill it??

Pls give some hints, many thnx!


SCJP 5.0 - 98% (2007)<br />SCWCD 1.4 - 97% (2007)
Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 41108
    
  45
If you find a command-line tool that kills processes (not sure if those exist for Windows), you can use java.lang.Runtime.exec to execute it.


Ping & DNS - my free Android networking tools app
Jesper de Jong
Java Cowboy
Saloon Keeper

Joined: Aug 16, 2005
Posts: 14074
    
  16

You can download a "kill" utility for Windows here:
Sysinternals PsKill


Java Beginners FAQ - JavaRanch SCJP FAQ - The Java Tutorial - Java SE 7 API documentation
Scala Notes - My blog about Scala
Jon Lee
Ranch Hand

Joined: Mar 04, 2005
Posts: 134
Many thnx, mates! That works!
Kudret Serin
Ranch Hand

Joined: Aug 02, 2005
Posts: 167

If you find a command-line tool that kills processes (not sure if those exist for Windows), you can use java.lang.Runtime.exec to execute it.


Taskkill command.
You can see the usage with taskkill /?
Cheers.
Henry Wong
author
Sheriff

Joined: Sep 28, 2004
Posts: 18529
    
  40

Originally posted by Kudret Serin:

Taskkill command.
You can see the usage with taskkill /?
Cheers.


The taskkill command only works for windows xp professional. Believe it or not, it is not even built into windows xp home edition. Luckily, most business use the professional edition.

If you are using windows 2000 or 2003, I would look to see if the resource kit is installed. Again, most business client seems to install this package. In this package, there is a "kill" command.

Henry


Books: Java Threads, 3rd Edition, Jini in a Nutshell, and Java Gems (contributor)
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
 
subject: How to kill a windows process using java?
 
Similar Threads
how kill process
Equivalent kill -n for process.destroy()
Getting error while starting weblogic 10.3 server from start\programs\oraweblogic\....
Killing process using C language
How to kill rmiregistry on Linux?