Me and couple of my friends are using a shared folder on Dropbox, where've uploaded our minecraft server. The point of this is that anyone can launch a server at any time, insted of one person having to run it all the time.
The only problem is, two people might launch the server at the same time, and overlapping save files might occur. To combat this, I want to write a simple batch file.
The logic is this:
IF the process "minecraft_server.1.8.1" is running, rename the the server folder to "RUNNING AS _INSERT_NAME_HERE_", ELSE rename it back to "Minecraft server"
The NAME would be read as a computer name (if that's at all possible), or from some txt file that a user would create (to write their own name)
I've never written a batch file and I don't know if this is possible, but it seems simple enough and any help would be appreciated.
Thank you in advance.
Ok so after a bit of tinkering, I wrote my first batch file. For the most part it seems to be working, however I can't seem to implement a proper loop.
@echo off
IF EXIST *_RUNNING.txt (
echo "ERROR, SERVER ALREADY RUNNING as %computername%"
pause
EXIT
) ELSE (
copy NUL %computername%_RUNNING.txt
START /WAIT minecraft_server.1.8.1.exe
tasklist /FI "IMAGENAME eq javaw.exe" 2>NUL | find /I /N "javaw.exe">NUL
:loop
IF "%ERRORLEVEL%"=="0" (
TIMEOUT /t 5
GOTO loop
) ELSE (
del %computername%_RUNNING.txt
echo "Server ended."
pause
EXIT ) )
When I start minecraft_server.1.8.1.exe it then launches javaw.exe, and that is the actual process that starts the server. After that I just check if the process is still running or not. However I can't seem to loop that particular part of the code, I keep getting synatx errors.