Win a copy of The Java Performance Companion this week in the Performance forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

how to run a .bat file from java program.

 
Neeba Rebbaca
Ranch Hand
Posts: 162
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
A .bat file will be running in the system. If the bat file is not running, i want to run it from my java program. my problem here is how to detect whether the .bat file is runninf or not??
 
Pavan Kumar Dittakavi
Ranch Hand
Posts: 106
Eclipse IDE Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

I Googled and I could fin this method "window.enumerateProcess". Apparently this returns the handles of all currently running processes!..may be you could check on this

Thanks,
Pavan.
 
Henry Wong
author
Marshal
Pie
Posts: 21200
81
C++ Chrome Eclipse IDE Firefox Browser Java jQuery Linux VI Editor Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Instead of going to the Windows API, which will require that you go through something like JNI, it may be easier just to use runtime exec, and call the windows "tasklist" command.

Henry
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic