My minecraft server tends to crash fairly often so I wrote a script that checks my minecraft server, if its up it does nothing, if it is down it executes this code:
Set oShell= CreateObject("WScript.Shell")
strProcess = "cmd.exe"
oShell.Run "TaskKill /im " & strProcess & " /f /t", , True
WScript.sleep 1000
oShell.Run "c:\minecraft_launch.bat"
Set oShell = Nothing
Basically I kill any currently running server (cmd since it is being run from a batch file) then I start it back up. This check is run every 5mins via task scheduler.
This is the contents of the batch file:
@echo off
"C:\Program Files\Java\jre6\bin\java.exe" -Xmx1024M -Xms1024M -jar "%appdata%\- minecraft_server\minecraft_server.jar" >> "%appdata%\- minecraft_server\s.log"
When I run it, it works. Everytime, but…..When it runs automatically, it stops working. I don’t know how many times it will work until it quits. What happens is I notice it is down, so I check my computer. No server running, no process running, no javaw.exe or cmd.exe running. Nothing, but when I try to start the server it won’t start. I have to reboot the whole machine to get the server to start. I think I am missing something stupid simple here. Any ideas?
The problem could be that the timeout is too short so you try to start it while it’s still being closed. In any way, vbscript itself can check and terminate processes with more controll. See http://www.activexperts.com/activmonitor/windowsmanagement/adminscripts/processes/ for short scripts that monitor and stop processes.
Here a script from Rob Van der woude which usually are reliable, this monitors outlook.exe so i guess you would be monitoring javaw.exe