程序中这样写:
try {
//关闭bat
Process ps = Runtime.getRuntime().exec("cmd /k start G:\\close.bat");
ps.waitFor();
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (InterruptedException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
close.bat文件:
@echo off
echo 关闭bat
CMDOW "spider程序" /cls
pause & exit
这个是运行bat里的内容:
set DAEMON_COMMANDER=com/test/test
set DAEMON_HOME=../ttt
set DAEMON_LIB_PATH=%DAEMON_HOME%\lib\
set DAEMON_CLASSPATH=%DAEMON_HOME%\bin;%DAEMON_LIB_PATH%dom4j-1.6.1.jar;%DAEMON_LIB_PATH%mysql-connector-java-3.0.16-ga-bin.jar;
title spider程序
:start
java -cp %DAEMON_CLASSPATH% %DAEMON_COMMANDER% 11
ping 127.0.0.1 -n 5
goto start