HI Guys
I have tested following code this working on Win..XP, over java 1.5++.
To test this code you need to create three different files.
1. RunBatFile.java
2. RunByJava.bat
3. testFile.bat
I hope it will help us to see execution of bat file using java.
All the best.
package batfile;
import java.io.*;
class RunBatFile{
public static void main(String args[]){
try {
Runtime rt = Runtime.getRuntime();
rt.exec("RunByJava.bat");
System.out.println("Process exitValue: ");
} catch (Exception e) {
System.out.println("Unexpected exception Trying to Execute Job: " +e);
}
}
}
*************************************
RunByJava.bat
-------------------------
echo off
ECHO Starting TCP Monitor for Blue Martini
START/MIN CALL testFile
***************************
testFile.bat
----------------------
set tDate=%DATE%
ECHO todays date is %tDate%
SLEEP 5