0

By using the below code i can run batch file

Process p = Runtime.getRuntime().exec("E:/web_chat_temp/RunOpenfire/RunMe.bat");

But here how can i get pocess id of this process.

coz i need to stop in other application...

thanks

Rajesh Vaddepally
  • 353
  • 1
  • 5
  • 14
  • 2
    Maybe let the subprocess print its pid into stdout? – xiaofeng.li Jul 19 '12 at 11:19
  • check this link -- http://stackoverflow.com/questions/3643939/java-process-with-input-output-stream – NPKR Jul 19 '12 at 11:20
  • 2
    Don't always rely upon `Runtime.getRuntime().exec()`. Use [ProcessBuilder](http://docs.oracle.com/javase/7/docs/api/java/lang/ProcessBuilder.html) instead. Have a look at [this](http://0guzhan.blogspot.in/2011/01/process-builder-demo.html) example. – Lion Jul 19 '12 at 11:23

1 Answers1

1

Assuming that you running this program in windows machine & also you running the other app in windows.

you use the command

tasklist or tasklist [process name]

to get its process id.

Shafi Ulla
  • 79
  • 5