N
N
NeoLight32020-10-04 13:01:47
cmd/bat
NeoLight3, 2020-10-04 13:01:47

How to kill a process when a subprocess is detected?

I have a server application that can crash.
Previously, I put a script that detects when an application (server) is not responding, and kills its process, and then starts a new one:

@ECHO OFF
:CHECK
TASKLIST /NH /FI "IMAGENAME EQ Unturned.exe" /FI "STATUS EQ RUNNING" | FIND /I ":" > NUL
IF %ERRORLEVEL%==0 GOTO NOT_RUNNING
TIMEOUT /T 10 /NOBREAK
GOTO CHECK
:NOT_RUNNING
TASKKILL -F /IM Unturned.exe
START Unturned.exe -pvp -port:25444 -normal -pei -players:32 -sv -nographics -nosync
TIMEOUT /T 10 /NOBREAK
GOTO CHECK


However, later it turned out that this is not the only problem, it turns out that the application can crash without the inscription "Not responding", something like this:
5f799d3be5e89276111886.png

And at the same time, the "Oops" subprocess appeared in the application.
5f799d638f752592099108.png

How can I modify my previous script so that it detects such a crash, and also kills the process and starts a new one?
Thank you.

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question