serv.bat 1.6 KB

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