新建txt,编写,前台启动,出现cmd黑窗口
@echo off
start java -jar zhoao1.jar
start java -jar zhoao2.jar
pause
完成后,重命名.bat
1、后台启动,不出现cmd黑窗口,app是窗口名称
@echo off
start "名称" javaw -jar zhoao1.jar
start "名称" javaw -jar zhoao2.jar
pause
2、关闭
@echo off
set port=9001
for /f "tokens=1-5" %%i in ('netstat -ano^|findstr ":%port%"') do (echo kill the process %%m who use the port taskkill /pid %%m -t -f
)
set port1=9002
for /f "tokens=1-5" %%i in ('netstat -ano^|findstr ":%port1%"') do (echo kill the process %%m who use the port1 taskkill /pid %%m -t -f
)
:q
3、重启
@echo off
set port=9001
for /f "tokens=1-5" %%i in ('netstat -ano^|findstr ":%port%"') do (echo kill the process %%m who use the port taskkill /pid %%m -t -f
)
set port1=9002
for /f "tokens=1-5" %%i in ('netstat -ano^|findstr ":%port1%"') do (echo kill the process %%m who use the port1 taskkill /pid %%m -t -f
)
:start
start "app" javaw -jar zhoao1.jar
start "app" javaw -jar zhoao2.jar