Granny's Programming Pearls
"inside of every large program is a small program struggling to get out"
JavaRanch.com/granny.jsp
Win a copy of Clojure in Action this week in the Clojure forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

How to kill a windows process using java?

 
Jon Lee
Ranch Hand
Posts: 134
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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!
 
Ulf Dittmer
Rancher
Pie
Posts: 42966
73
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
Jesper de Jong
Java Cowboy
Saloon Keeper
Pie
Posts: 15150
31
Android IntelliJ IDE Java Scala Spring
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You can download a "kill" utility for Windows here:
Sysinternals PsKill
 
Jon Lee
Ranch Hand
Posts: 134
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Many thnx, mates! That works!
 
Kudret Serin
Ranch Hand
Posts: 167
Android Eclipse IDE Ubuntu
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Marshal
Pie
Posts: 20836
75
C++ Chrome Eclipse IDE Firefox Browser Java jQuery Linux VI Editor Windows
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
I agree. Here's the link: http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic