• 1

posted a message on Windows Auto-restart Script
I wonder why no one commented on this, it's actually very useful and I'm a big fan of batch files even though they are SO limited in Widows. ^^

However, I'd prefer if you used another variable than "path", which is also a system variable. Setting it this way of course sets it only locally for the execution of the .bat but it still shouldn't be done that way.

Ah, also, the script should wait before restarting, otherwise you get no time to close the server for good when using the stop command. If you're on Vista+ you have access to the timeout /t command - previously you had to do some nonsensical ping >nul magic to get sleeps/waits/timeouts.

Modified version of your script:

@echo off
title Minecraft Server
set server="P:\ath\to\minecraft_server.jar"

:minecraft
echo (%time%) Minecraft SMP started.
start /B /wait java -jar -Xmx1024M -Xms1024M %server% nogui
echo (%time%) WARNING: Minecraft SMP closed or crashed, restarting.
timeout /t 10 /nobreak
goto minecraft
Posted in: Alpha - Survival Multiplayer Discussion