Answer the question
In order to leave comments, you need to log in
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
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question