Batch file to ping server list | Windows

Batch Scripting

To check whether a windows server is online or not below is the batch file which will help determine a server is up or not. We can use below functions to create our own script to ping server list.  Through below functions we can execute the batch file ping test easily and reliably.

Ping -n 1 -w 1000 %servername% > nul
REM Echo PingErrLvl:%Errorlevel% & Pause
IF %ErrorLevel% NEQ 0 (
ECHO Connection test to %servername% failed.

ECHO Terminating Batch execution...
ECHO Inputs to machineol.bat are Case-sensitive. Re-Check the options.
) ELSE (
REM ErrLvl 0 means successfully PING
ECHO SUCCESS:Connection Test To %servername%
GOTO EndOnlineTest

Change the %servername% to the original server hostname which you want to check whether the server is online and pingable.

In case of any ©Copyright or missing credits issue please check CopyRights page for faster resolutions.

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.