batch file examples (restart - monitor)

This commit is contained in:
DESKTOP-UH65DCE\MusTanG 2017-12-19 10:29:39 -06:00
parent f59defbb5a
commit 83e90a964d
2 changed files with 57 additions and 0 deletions

View File

@ -0,0 +1,34 @@
@echo off
:: Turn off all firewall rules
echo Disabling firewall rules for this server
netsh advfirewall firewall delete rule name="a3Epoch" program="C:\EpochServer\Epochserver_x64.exe"
timeout 2
:: MAKE SURE ALL TASKS ARE REALLY STOPPED
echo Making sure all instances of this server have stopped
taskkill /f /fi "status eq not responding" /im Epochserver_x64.exe
taskkill /f /im Epochserver_x64.exe
timeout 2
:: RESTARTING THE ARMA 3 SERVER BE SURE TO EDIT THIS TO YOUR SERVER .EXE LOCATION -NOTE ALSO THIS IS WHERE YOU DEFINE WHERE YOU CONFIG.CFG IS
echo Starting ARMA 3 Server...
C:\Windows\System32\cmd.exe /C start "arma3" "C:\EpochServer\Epochserver_x64.exe" "[email protected];" "[email protected];" -config=C:\EpochServer\sc\server.cfg -port=2302 -profiles=sc -cfg=C:\EpochServer\sc\basic.cfg -name=sc -BEPath=C:\EpochServer\battleye -autoINIT -Loadmissiontomemory
echo ARMA 3 Server has started
timeout 60
:: THIS RUNS THE SERVER MONITOR FOR YOU SO YOU DON'T FORGET
echo Starting Server Monitor Loop
set ServerMonitorPath="C:\Epochserver"
cd /d %ServerMonitorPath%
start "" "servermonitor.bat"
echo Server Monitor has started. Have Fun
timeout 5
:: Turn On Firewall rule
timeout 10
echo Turning on Firewall Rule to allow server network traffic
netsh advfirewall firewall add rule name="a3Epoch" dir=in action=allow program="C:\Epochserver\Epochserver_x64.exe" enable=yes
echo Firewall is on and players can join
timeout 5
@exit

View File

@ -0,0 +1,23 @@
@echo off
::IMPORTANT TO NAME IT SO WE CAN KILL IT
title servermonitor.bat
:start
C:\Windows\System32\tasklist /FI "IMAGENAME eq Epochserver_x64.exe" 2>NUL | C:\Windows\System32\find /I /N "Epochserver_x64.exe">NUL
if "%ERRORLEVEL%"=="0" goto loop
echo Server is not running, will be started now
start "" /min /wait "c:\EpochServer\restartserver_x64.bat - Shortcut"
timeout 30
echo Server started succesfully
exit
goto started
:loop
cls
echo Server is already running, running monitoring loop
:started
::THE 80 REFERS TO SECONDS AND HOW OFTEN IT WILL CHECK,YOU CAN SET IT TO WHATEVER YOU WANT. I JUST DONT WANT MY SERVER DOWN FOR MUCH LONGER THAN THAT!
::New error fault kill, will check for err fault and clear it and hopefully restart, a little more promise but no guarantee :)
taskkill /f /im WerFault.exe /fi "WINDOWTITLE eq Arma 3"
C:\Windows\System32\timeout /t 150
C:\Windows\System32\tasklist /FI "IMAGENAME eq Epochserver_x64.exe" 2>NUL | C:\Windows\System32\find /I /N "Epochserver_x64.exe">NUL
if "%ERRORLEVEL%"=="0" goto loop
goto start