The following quick and dirty test script does accomplish the above, but the service console then fails to get back a handle on the service
@echo off
@rem ---------------------------------------------------------------------------
@rem Usrdata
@rem ---------------------------------------------------------------------------
set SVCNAM=OurService
set PROCJAV=javaw.exe
set PROCSVC=Mendix.Service.exe
set INTERV=1
@rem ---------------------------------------------------------------------------
@rem Main
@rem ---------------------------------------------------------------------------
goto monitor
@rem ----------------------------------------------------------------------------
@rem Monitor Loop
@rem ----------------------------------------------------------------------------
:monitor
call :prgcheck
timeout /t %INTERV% >NUL
goto monitor
@rem ----------------------------------------------------------------------------
@rem Check Processes
@rem ----------------------------------------------------------------------------
:prgcheck
tasklist /FI "IMAGENAME eq %PRGNAM%" 2>NUL | find /I /N "%PRGNAM%">NUL
if "%ERRORLEVEL%"=="0" (
echo %time%: Mendix Running
) else (
echo %time%: Mendix Not Running : Restarting...
@rem -----------------------------------------------------------------------------
@rem Kill
@rem -----------------------------------------------------------------------------
taskkill /f /im %PROCSVC% > nul 2>&1
taskkill /f /im %PROCJAV% > nul 2>&1
@rem -----------------------------------------------------------------------------
@rem Start
@rem -----------------------------------------------------------------------------
net start %SVCNAM%
)