@echo off
title test
tasklist|find /i "test.exe"
if "%errorlevel%"=="1" (goto end) else (goto start)
:end
echo 系统程序不存在!
pause
exit
:start
echo 发现系统进程!
echo 开始卸载系统进程......
taskkill -f -t -im test.exe
echo 卸载系统进程结束......
pause
tasklist命令找到该程序的进程,taskkill杀掉该进程。
tomcat的启动、结束bat都是调用org.apache.catalina.startup.Bootstrap这个类实现的,startup.bat最终会执行Bootstrap.java里的
public void start() throws Exception {if( catalinaDaemon==null ) init()
Method method = catalinaDaemon.getClass().getMethod("start", (Class [] )null)
method.invoke(catalinaDaemon, (Object [])null)
}
shutdown.bat最终会执行Bootstrap里的
public void stopServer() throws Exception {Method method = catalinaDaemon.getClass().getMethod("stopServer", (Class []) null)
method.invoke(catalinaDaemon, (Object []) null)
}
你也可以这样写一个类来控制程序的启动、终止,bat就调用对应的方法。
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)