This page contains an archived post to the Java Answers Forum made prior to February 25, 2002.
If you wish to participate in discussions, please visit the new
Artima Forums.
Message:
RE: Running .bat file thru Java file
Posted by Kishori Sharan on January 01, 2001 at 8:32 PM
Construct the command string at run time as String cmd = "abc.bat" ; String p1, p2, p3 ; // Populate p1, p2 and p3 at run time // Construct the final command string cmd = cmd + " " + p1 + " " + p2 + " " + p3 ; Runtime.getRuntime().exec ( cmd ) ; OR ......... You can also pass a string array which holds the command and arguments to exec ( ) methods as String[] cmd = new String[4] ; cmd[0] = "abc.bat" ; cmd[1] = p1 ; // p1 will be populated at run time cmd[2] = p2 ; cmd[3] = p3 ; Runtime.getRuntime().exec ( cmd ) ; If you want to pass different no. of parameter then you will have to create different array cmd of different size... Thanx Kishori
Replies:
- Thanx Girish B January 02, 2001 at 7:43 AM
(1)
- Try this... Kishori Sharan January 02, 2001 at 9:30 AM
(0)
|