File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Java in General and the fly likes how to run a .bat file from java program. Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Java » Java in General
Bookmark "how to run a .bat file from java program." Watch "how to run a .bat file from java program." New topic
Author

how to run a .bat file from java program.

Neeba Rebbaca
Ranch Hand

Joined: Oct 21, 2008
Posts: 148
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

Joined: Feb 12, 2011
Posts: 104

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
Sheriff

Joined: Sep 28, 2004
Posts: 18498
    
  40


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


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 run a .bat file from java program.
 
Similar Threads
'.dat' file Question.
run bat file within java
How to make exe file?
How to make exe in JBuilder 3 Professional
classpath problem