Determine if Tomcat is running in Windows using the command prompt

后端 未结 10 1708
陌清茗
陌清茗 2020-12-15 06:24

Quite simply, how does one determine whether or not Tomcat is running in Windows, using the command prompt?

I am writing a batch script that must do this. This is

10条回答
  •  挽巷
    挽巷 (楼主)
    2020-12-15 06:57

    Using WMIC

    @echo off
    wmic process list brief | find /i "tomcat.exe"
    set result=%ERRORLEVEL%
    if "%result%"=="1" echo "not running"
    if "%result%"=="0" echo "running"
    

    note : /i is to make the find operation case-insensitive.

提交回复
热议问题