Originally posted by VIJAY Yadlapati:
The output generated by the .bat file is being considered as the name of an executable file unless you specifically use ECHO command.
Here is the code I have tried and it's working fine.
a.bat
*****
ECHO INDIA
--------------------------
Runtime runtime = Runtime.getRuntime();
try
{
Process p1 = runtime.exec("cmd /c D:\\temp\\a.bat");
InputStream is = p1.getInputStream();
int i = 0;
while( (i = is.read() ) != -1)
{
System.out.print((char)i);
}
}
catch(IOException ioException)
{
System.out.println(ioException.getMessage() );
}
-----------------------------------------------------
OutPut
******
D:\eclipse\workspace\Temp>ECHO INDIA
INDIA
Hi Vijay,
Thank you for ur reply. Actually I tried on this manner but it gave me some error(not exacly error but the process is not teminating).
So, I changed my command to the following ways and now its working...
Process p = runtime.exec("cmd /c start c:\\sunTest\\test.bat");
Thank you once again for ur answer.
Regards,
Sundeep.