"시작"의 B 옵션을 사용해 보셨습니까?
proc = Runtime.getRuntime().exec("cmd /c start /B somebat.bat");
편집 :
좋아, 아니시, 그 코드가 실행되지 않는 것이 재미있다.
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();
}
내 somebat.bat 파일은 다음과 같습니다 : 내 시나리오 작업 위의 시도 블록에서
rem somebat.bat:
d:
cd D:\temp\_test
copy somebat.bat somebat2.bat
모든 세 가지 버전
내가 단위 테스트를 설정합니다. Somebat.bat는 명령 창을 팝업하지 않고 somebat2.bat에 복사됩니다 (질문에 표시된 전화를 사용하면 어떻게됩니까?).
편집 2 : 다음 라운드 ;-)
아니시, 당신은 당신의 somebat.bat과 개미 파일과 같은 방법을 우리에게 보여줄 수있다?
내 시나리오 작업 아래의 세 가지 통화의 모든 때문에 :
테스트 코드 :
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.박쥐 :
는
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 : 임의의 텍스트 파일
종료 스크립트를 배치 스크립트 끝에 추가하십시오. –