@echo off :: This batch file uses the http-ping application to detect when :: a web server is not responding, or returns an invalid response. :: It returns 0 if the server responds properly and 1 if not. :: It is intended for use with AlwaysUp :: (https://www.coretechnologies.com/products/AlwaysUp/) :: or Service Protector :: (https://www.coretechnologies.com/products/ServiceProtector/). :: Copyright © Core Technologies Consulting, LLC. All :: rights reserved. :: Here are a few variables that you should adjust. ::================================================== :: ** Please specify the URL you wish to ping, and the full path :: to the http-ping executable on your system ** SET url=http://localhost:80 SET http-ping-exe-path="C:\Temp\http-ping.exe" :: We'll save the HTTP responses to this file. :: ** Please change it to a path that exists on your system ** SET response-file=C:\temp\http-responses.txt :: And we will consider the web server as "failed" if the response :: contains this text. :: ** Please set it to whatever works for your situation ** SET bad-text="Internal Server Error 500" :: Clear the file that logs the HTTP responses DEL /F %response-file% :: Ping your web server. %http-ping-exe-path% -f %response-file% %url% :: Exit code of 0 ==> all failed ==> return 1 to have AlwaysUp :: restart the application IF %ERRORLEVEL% EQU 0 GOTO failure :: At least one ping attempt received a response. :: Check the response file for the "bad" text. type %response-file% | find %bad-text% >nul 2>&1 :: Failed if the text is found IF %ERRORLEVEL% EQU 0 GOTO failure :: Text was not found. :success echo Succeeded! exit 0 :failure echo Failed! exit 1