Update to use findstr

This commit is contained in:
ineedbots 2021-10-24 02:17:14 -06:00
parent 7b667f511d
commit af35ec3a8f
3 changed files with 34 additions and 10 deletions

View File

@ -1,6 +1,10 @@
@echo off @echo off
::Name of the server's title ::Name
set name=Bot Warfare Players vs bots 24/7 Rust 10x set name=IW4x Bot Warfare PvB Rust
::Exe of the server
set server_exe=iw4x.exe
::The regex search for the window name of the server
set server_title_regex=Bot Warfare Players vs bots 24/7 Rust 10x
::Only change this when you don't want to keep the bat files in the game folder. MOST WON'T NEED TO EDIT THIS! ::Only change this when you don't want to keep the bat files in the game folder. MOST WON'T NEED TO EDIT THIS!
set gamepath=%cd% set gamepath=%cd%
::Rate to check if server is hung ::Rate to check if server is hung
@ -25,6 +29,10 @@ for /f "delims=" %%i in ('"forfiles /p "%log_path%" /m "%log_file%" /c "cmd /c e
if "%modif_time_temp%" == "%modif_time%" ( if "%modif_time_temp%" == "%modif_time%" (
echo "(%date%) - (%time%) WARNING: %name% server hung, killing server..." echo "(%date%) - (%time%) WARNING: %name% server hung, killing server..."
taskkill /FI "WINDOWTITLE eq %name%" /F ::https://stackoverflow.com/questions/26552368/windows-batch-file-taskkill-if-window-title-contains-text
for /f "tokens=2 delims=," %%a in ('
tasklist /fi "imagename eq %server_exe%" /v /fo:csv /nh
^| findstr /r /c:"%server_title_regex%"
') do taskkill /pid %%a /f
) )
goto Server goto Server

View File

@ -1,6 +1,10 @@
@echo off @echo off
::Name of the server's title ::Name
set name=Bot Warfare Players vs bots Mapvote 10x set name=IW4x Bot Warfare PvB Vote
::Exe of the server
set server_exe=iw4x.exe
::The regex search for the window name of the server
set server_title_regex=Bot Warfare Players vs bots Mapvote 10x
::Only change this when you don't want to keep the bat files in the game folder. MOST WON'T NEED TO EDIT THIS! ::Only change this when you don't want to keep the bat files in the game folder. MOST WON'T NEED TO EDIT THIS!
set gamepath=%cd% set gamepath=%cd%
::Rate to check if server is hung ::Rate to check if server is hung
@ -25,6 +29,10 @@ for /f "delims=" %%i in ('"forfiles /p "%log_path%" /m "%log_file%" /c "cmd /c e
if "%modif_time_temp%" == "%modif_time%" ( if "%modif_time_temp%" == "%modif_time%" (
echo "(%date%) - (%time%) WARNING: %name% server hung, killing server..." echo "(%date%) - (%time%) WARNING: %name% server hung, killing server..."
taskkill /FI "WINDOWTITLE eq %name%" /F ::https://stackoverflow.com/questions/26552368/windows-batch-file-taskkill-if-window-title-contains-text
for /f "tokens=2 delims=," %%a in ('
tasklist /fi "imagename eq %server_exe%" /v /fo:csv /nh
^| findstr /r /c:"%server_title_regex%"
') do taskkill /pid %%a /f
) )
goto Server goto Server

View File

@ -1,10 +1,14 @@
@echo off @echo off
::Name of the server's title ::Name
set name=Bot Warfare 24/7 Rust 10x set name=IW4x Bot Warfare Server
::Exe of the server
set server_exe=iw4x.exe
::The regex search for the window name of the server
set server_title_regex=Bot Warfare 24/7 Rust 10x
::Only change this when you don't want to keep the bat files in the game folder. MOST WON'T NEED TO EDIT THIS! ::Only change this when you don't want to keep the bat files in the game folder. MOST WON'T NEED TO EDIT THIS!
set gamepath=%cd% set gamepath=%cd%
::Rate to check if server is hung ::Rate to check if server is hung
set check_rate=300 set check_rate=3
::Server log location ::Server log location
set log_path=%gamepath%\userraw\logs\server set log_path=%gamepath%\userraw\logs\server
set log_file=games_mp.log set log_file=games_mp.log
@ -25,6 +29,10 @@ for /f "delims=" %%i in ('"forfiles /p "%log_path%" /m "%log_file%" /c "cmd /c e
if "%modif_time_temp%" == "%modif_time%" ( if "%modif_time_temp%" == "%modif_time%" (
echo "(%date%) - (%time%) WARNING: %name% server hung, killing server..." echo "(%date%) - (%time%) WARNING: %name% server hung, killing server..."
taskkill /FI "WINDOWTITLE eq %name%" /F ::https://stackoverflow.com/questions/26552368/windows-batch-file-taskkill-if-window-title-contains-text
for /f "tokens=2 delims=," %%a in ('
tasklist /fi "imagename eq %server_exe%" /v /fo:csv /nh
^| findstr /r /c:"%server_title_regex%"
') do taskkill /pid %%a /f
) )
goto Server goto Server