serv.bat 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  1. @ECHO OFF
  2. IF "%1"=="" GOTO DIRECT
  3. IF "%2"=="" GOTO DIRECT
  4. IF NOT EXIST "%1" GOTO NOTFOUND
  5. IF "%3"=="" ( set "restart_mode=on"
  6. ) else set "restart_mode=%~3"
  7. echo "restart_mode=%restart_mode%"
  8. GOTO START_RA
  9. REM == How RESTART_9X and RESTART_NT works =========================
  10. REM On Windows 9x only the first 8 characters are significant for
  11. REM labels, and the first matching one is called (RESTART_(9X)).
  12. REM Windows NT calls the exact named label (RESTART_NT).
  13. REM Separation between 9X and NT is required, because CHOICE has
  14. REM different syntax on these platforms or does not exist as all.
  15. REM ================================================================
  16. REM Windows 95, 98, ME
  17. :RESTART_9X
  18. REM Old Ctrl+C in PING does not work, because that only stops ping,
  19. REM not the batch file.
  20. CHOICE /C:rc /N /T:R,15 Restarting in 15 seconds, press 'C' to cancel.
  21. IF NOT ERRORLEVEL 2 GOTO START_RA
  22. GOTO END
  23. REM Windows 2000, XP, Vista, 7
  24. :RESTART_NT
  25. REM There is no CHOICE in 2000 and XP, but you get asked whether to
  26. REM abort the batch file, when pressing Ctrl+C in PING.
  27. IF "%1"=="mapcache.exe" GOTO END
  28. if "%restart_mode%" == "off" GOTO END
  29. ECHO Restarting in 15 seconds, press Ctrl+C to cancel.
  30. PING -n 15 127.0.0.1 > NUL
  31. :START_RA
  32. %1
  33. ECHO.
  34. REM Return value 1 is EXIT_FAILURE
  35. IF ERRORLEVEL 1 GOTO EXIT1
  36. REM Return value is not 0 the process has crashed
  37. IF NOT ERRORLEVEL 0 GOTO CRASHED
  38. REM Return value 0 is EXIT_SUCCESS
  39. ECHO %2 has shutdown successfully.
  40. GOTO RESTART_NT
  41. :EXIT1
  42. ECHO %2 has terminated abnormally.
  43. GOTO RESTART_NT
  44. :CRASHED
  45. ECHO %2 has crashed!
  46. GOTO RESTART_NT
  47. :DIRECT
  48. ECHO Do not run this file directly. It is used by logserv.bat, charserv.bat,
  49. ECHO mapserv.bat and their '-server' counterparts.
  50. GOTO END
  51. :NOTFOUND
  52. ECHO %1 was not found. Make sure, that you have compiled the %2.
  53. GOTO END
  54. :END
  55. PAUSE