通过 java web 应用程序执行批处理文件时,出现以下描述的错误。
我不知道为什么只有案例 1 按预期工作,在案例 2、3、4 中,只执行部分批处理文件。任何人都可以向我解释为什么?非常感谢。
使用执行命令Runtime.getruntime().exec(command)
case1. cmd /c start C:\mytest.bat
case2. cmd /c start /b C:\mytest.bat
case3. cmd /c C:\mytest.bat
case4. C:\mytest.bat
mytest.bat
echo line1 >>%~dp0test.txt
echo line2 >>%~dp0test.txt
echo line3 >>%~dp0test.txt
echo line4 >>%~dp0test.txt
echo line5 >>%~dp0test.txt
echo line6 >>%~dp0test.txt
echo line7 >>%~dp0test.txt
echo line8 >>%~dp0test.txt
echo line9 >>%~dp0test.txt
echo line10 >>%~dp0test.txt
echo line11 >>%~dp0test.txt
echo line12 >>%~dp0test.txt
echo line13 >>%~dp0test.txt
echo line14 >>%~dp0test.txt
echo line15 >>%~dp0test.txt
echo line16 >>%~dp0test.txt
echo line17 >>%~dp0test.txt
echo line18 >>%~dp0test.txt
echo line19 >>%~dp0test.txt
echo line20 >>%~dp0test.txt
exit
结果test.txt
情况1:
line1
line2
line3
line4
line5
line6
line7
line8
line9
line10
line11
line12
line13
line14
line15
line16
line17
line18
line19
line20
案例2、3、4:
line1
line2
line3
line4
line5