-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathworldserver-exitcode-script.bat
55 lines (49 loc) · 1.43 KB
/
worldserver-exitcode-script.bat
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
@echo off
:start
worldserver.exe
:: For SHUTDOWN_EXIT_CODE
if %errorlevel% == 0 (
echo Server has Shutdown and will not automatically restart.
echo Shutdown Code is %errorlevel% SHUTDOWN_EXIT_CODE
echo Press any key to restart WorldServer, press CTRL + C to exit.
pause
goto start
)
:: For RESTART_EXIT_CODE
if %errorlevel% == 2 (
echo WorldServer will restart.
echo Shutdown Code is %errorlevel% RESTART_EXIT_CODE
echo Restarting in 15s.
timeout /t 15 /nobreak
goto start
)
:: For a custom shutdown code "15"
:: if %errorlevel% == 15 (
:: echo Shutdown Code is %errorlevel%
:: echo Press any key to restart WorldServer.
:: pause
:: goto start
:: )
:: For ERROR_EXIT_CODE
if %errorlevel% == 1 (
echo Server has encountered an error.
echo Shutdown Code is %errorlevel% ERROR_EXIT_CODE
echo Press any key to restart WorldServer, press CTRL + C to exit.
pause
goto start
)
:: As batch doesn't have logical operators...
:: This is what we have to do to not break the script if an
:: unknown errorlevel is provided.
if NOT %errorlevel% == 0 (
if NOT %errorlevel% == 1 (
if NOT %errorlevel% == 2 (
echo Shutdown Code is unknown.
echo Shutdown Code is %errorlevel%
echo Maybe this was a misstake? WorldServer will restart in 60s
echo Press CTRL + C to cancel.
timeout /t 60
goto start
)
)
)