Check the up/down status of servers and services with a batch file

Here is a template for a batch file you can run on demand to check the up/down status of servers and services using the command prompt.

Most companies will be using some sort of automated tool for monitoring the status of their servers however if you don’t have the budget or want something quick to use here is something you can setup which pings as many servers or services as you want and outputs their status to a text file which can quickly be scanned to find out if any have gone down unexpectedly.

Or maybe you pushed out a windows patch to all your machines and want to check everything has come back up after reboots?


  • Copy and Paste the below script into a text file and save it using any name but with a .bat extension
  • Place it in c:\X\       (if needed you can change this location in the script)
  • Edit the bat file and replace #SERVER and #SERVICENAME with whatever you are checking. The service name can be found in the properties 1
  • It should look like this:2
  • When you run the batch file it will output all the raw data into a file called servicestatus.txt then clean it up and place the final output into a file called FinalReport.txt which you can easily scan to see which servers either haven’t responded to ping or which services are showing as stopped.34



REM ———————–SECTION 1————————————–

REM This checker has 4 sections

REM Section 1 = Version details and notes

REM Section 2 = Pings a list of servers to ensure they are up

REM Section 3 = Contacts a list of services to ensure they are up

REM section 4 = Gets the raw output of sections 2+3 and removes unwanted lines, then outputs the results to finalreport.txt

REM ———————–SECTION 2————————————-

ping #SERVER1 >> c:/x/servicestatus.txt

ping #SERVER2 >> c:/x/servicestatus.txt

ping #SERVER3 >> c:/x/servicestatus.txt

REM ———————–SECTION 3—————————————-

sc \\#SERVER1 query #SERVICENAME >> c:/x/ServiceStatus.txt

sc \\#SERVER1 query #SERVICENAME >> c:/x/ServiceStatus.txt

sc \\#SERVER2 query #SERVICENAME >> c:/x/ServiceStatus.txt

sc \\#SERVER3 query #SERVICENAME >> c:/x/ServiceStatus.txt

sc \\#SERVER3 query #SERVICENAME >> c:/x/ServiceStatus.txt

REM ———————–SECTION 4———————————————–

findstr /v “statistics Packets Approximate Minimum TYPE WIN32 STOPPABLE SERVICE_EXIT_CODE CHECKPOINT WAIT_HINT” c:/x/servicestatus.txt > c:/x/FinalReport.txt

del “C:\X\servicestatus.txt” /f /q


Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s