| Author |
executing batch file from a java program
|
Neeraj Gupta
Greenhorn
Joined: Jun 21, 2003
Posts: 10
|
|
Hi, Can anyone please help me with code that how to execute a Windows based batch file through a simple java program. I tried Runtime.exec() but its not working. Assume that the batch file is kept at C:\ABC.bat Neeraj
|
 |
Lionel Badiou
Ranch Hand
Joined: Jan 06, 2005
Posts: 140
|
|
What about this ? Hope that helps,
|
Lionel Badiou
CodeFutures Software
|
 |
Lionel Badiou
Ranch Hand
Joined: Jan 06, 2005
Posts: 140
|
|
|
|
 |
Horatio Westock
Ranch Hand
Joined: Feb 23, 2005
Posts: 221
|
|
I think for a batch file, you have to pass it as a parameter to cmd.exe or command.com depending on your version of windows: e.g. rt.exec("cmd.exe /C C:/test.bat"); Or use an array for the parameter with the arguments, your choice.
|
 |
William Brogden
Author and all-around good cowpoke
Rancher
Joined: Mar 22, 2000
Posts: 12268
|
|
And remember that you have to provide for handling the output stream (std out) from the batch or it may never complete. This has been discussed here frequently, so browse the archives. Bill
|
 |
 |
|
|
subject: executing batch file from a java program
|
|
|