serv.bat 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  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. ECHO Restarting in 15 seconds, press Ctrl+C to cancel.
  25. PING -n 15 127.0.0.1 > NUL
  26. :START
  27. %1
  28. ECHO.
  29. REM Return value > 1 is exception&~0xC0000000
  30. IF ERRORLEVEL 2 GOTO CRASHED
  31. REM Return value 1 is EXIT_FAILURE
  32. IF ERRORLEVEL 1 GOTO EXIT1
  33. REM Return value 0 is EXIT_SUCCESS
  34. ECHO %2 has shutdown successfully.
  35. GOTO RESTART_NT
  36. :EXIT1
  37. ECHO %2 has terminated abnormally.
  38. GOTO RESTART_NT
  39. :CRASHED
  40. ECHO %2 has crashed!
  41. GOTO RESTART_NT
  42. :DIRECT
  43. ECHO Do not run this file directly. It is used by logserv.bat, charserv.bat,
  44. ECHO mapserv.bat and their '-server' counterparts.
  45. GOTO END
  46. :NOTFOUND
  47. ECHO %1 was not found. Make sure, that you have compiled the %2.
  48. GOTO END
  49. :END
  50. PAUSE