aspose file tools*
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


Win a copy of Spring in Action this week in the Spring forum!
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: 42280
    
  64
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: 14269
    
  21

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


Java Beginners FAQ - JavaRanch SCJP FAQ - The Java Tutorial - Java SE 8 API documentation
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: 18896
    
  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)
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: How to kill a windows process using java?