2016-10-28 103 views

回答

0

您可以使用此:

wmic process list brief | find /i "tomcat" 

要查看Tomcat正在運行。

您可以使用PowerShell太:

test-netconnection -computername <name or ip> -port <port number> 
get-process | select-string <process name> 

首先命令將檢查指定的端口監聽,如果指定的進程正在運行第二個將檢查。您可以按照您認爲合適的順序使用它們並檢查輸出。如果輸出不處於所需狀態,則可以進行睡眠並再次循環,直到tomcat爲止。

+0

我該如何使用wmic命令的輸出?是否類似於檢查錯誤級別?對不起,我沒有批處理命令的經驗 – lives

0
start "" tomcat.exe 
:loop 
timeout /t 1 >NUL 
tasklist /FI "imagename eq tomcat.exe" | findstr /I /C:"tomcat.exe" >NUL 
if errorlevel 1 goto loop 
chrome.exe http://%url% 

tasklist驗證,如果啓動的程序真的在運行。不要簡單地相信程序正確啓動

+0

請學習如何[格式](http://stackoverflow.com/help/formatting)代碼正確 - 請參閱[編輯](http://stackoverflow.com/revisions/40300897/2)... – aschipfl

+0

這沒有奏效。 – lives

+0

檢查你的tomcat exe文件是否包含版本號例如「tomcat8.exe」並相應地修改批處理文件。 – user2956477

相關問題