以下內容存成tomcat.bat即可
@echo off color 0b setlocal :#top01 cls echo 目前Apache Tomcat狀態為: sc queryex tomcat7 echo . set tomcatstat=none set /p tomcatstat="請輸入1.查看狀態(或任意鍵) 2.重啟Tomcat 3.停止Tomcat 4.離開 5.呼叫服務:" if %tomcatstat%==1 goto #top01 if %tomcatstat%==2 goto #top02 if %tomcatstat%==3 goto #top03 if %tomcatstat%==4 goto #end04 if %tomcatstat%==5 goto #end05 endlocal goto #top01 :#top02 sc stop tomcat7 echo 稍等2秒鐘...... timeout 2 sc start tomcat7 echo Apache Tomcat 已重啟完成... timeout 5 endlocal goto #top01 :#top03 sc stop tomcat7 echo Apache Tomcat 已停止... timeout 5 endlocal goto #top01 :#end04 exit :#end05 start services.msc goto #top01 #write by Matt