Have you tried the B option of "start"?
proc = Runtime.getRuntime().exec("cmd /c start /B somebat.bat");
Edit:
Ok, Anish, that is funny that your code is not executed.
I set up a unit test:
Process proc = null;
try
{
proc = Runtime.getRuntime().exec("cmd /c start /B D:\\temp\\_test\\somebat.bat");
proc = Runtime.getRuntime().exec("cmd /c call D:\\temp\\_test\\somebat.bat");
proc = Runtime.getRuntime().exec("D:\\temp\\_test\\somebat.bat");
}
catch (IOException e)
{
// TODO Auto-generated catch block
e.printStackTrace();
}
My somebat.bat file looks like this:
rem somebat.bat:
d:
cd D:\temp\_test
copy somebat.bat somebat2.bat
All three versions in the try-block above work in my scenario. Somebat.bat is copied to somebat2.bat without a command window popping up (what happens, if I use your call, shown in your question).
Edit 2: Next round ;-)
Anish, can you show us how your somebat.bat and your ant file looks like?
Because all of the three calls below work in my scenario:
test code:
Process proc = null;
proc = Runtime.getRuntime().exec("cmd /c start /B c:\\temp\\_test\\somebat.bat");
proc = Runtime.getRuntime().exec("cmd /c call c:\\temp\\_test\\somebat.bat");
proc = Runtime.getRuntime().exec("c:\\temp\\_test\\somebat.bat");
somebat.bat:
cd\temp\_test
ant mycopy
build.xml:
<?xml version="1.0"?>
<project name="testproj" default="mycopy" basedir=".">
<target name="mycopy">
<copy file="myfile.txt" tofile="mycopy.txt" />
</target>
</project>
myfile.txt: arbitrary text file