• RSS
  • Twitter
  • FaceBook

How To Check If A Service Is Running or Not On Multiple Servers

  • Section(s): Administrator, Admin , Admin
  • Published on Feb 16, 2011.
  • Last Modified on Jan 09, 2010.
  • Last Modified by Nirmal Sharma.
  • Rated 5 out of 5 based on 3 votes.
This article explains how you can use a small CMD script to check the status of a service on multiple computers.

Windows natively has a command line tool which can be used to check if a service is running or not on a remote computer. The utility/tool name is SC.exe. SC.exe has parameter to specify the remote computer name. You can check service status only on one remote computer at a time. You can use below script to check service status on multiple computers. Let's say we want to check the status of service called Windows Update.

Steps:

  1. Create a text file; Servers.txt
  2. Put all the server names in it.
  3. Next, copy the following lines in a file and save it as ChkService.CMD
  • REM ***START HERE***
  • Echo Off
  • Setlocal EnableDelayedExpansion
  • IF EXIST Result.csv DEL Result.csv
  • FOR /F "Tokens=*" %%L IN (Servers.txt) DO (
  •    SET ServerName=
  •    SET ServerName=%%L
  •    SC.exe \\!ServerName! Query Wuauserv > Result.txt
  • )
  • Find /i "RUNNING" < Result.txt
  • IF !ErrorLevel! == 0 (
  •     Echo !ServerName!, Running >> Result.csv
  • ) ELSE (
  •     Echo !ServerName!, Not Running >> Result.csv
  • )
  • REM ***END HERE***

The end results will be stored in the Result.csv file. The result.csv will have the server name and the service status (Running or Not Running). The ChkService.CMD can be executed from a computer running Windows Server 2003 or later Operating Systems.

About Nirmal Sharma

Nirmal is a Microsoft MVP in Directory Services and working as a Technical Architect/Consultant. He has been involved in Microsoft Technologies since 1994 and followed the progression of Microsoft Operating Systems and software. He is specialized in Directory Services, Microsoft Clustering, SQL, MOM, Exchange and Citrix. In his spare time, he likes to help others and write "internal" technical articles, white papers and tips on various Microsoft technologies. You can contact him at nirmal_sharma@mvps.org.


Article not looking right or info is missing? Let us know so that we can fix it: .


Receive all the latest articles by email!

Receive Real-Time & Monthly WindowsNetworking.com article updates in your mailbox. Enter your email below!
Click for Real-Time sample & Monthly sample

Become a WindowsNetworking.com member!

Discuss your network issues with thousands of other network administrators. Click here to join!

Community Area

Log in | Register

Readers' Choice

Which is your preferred data recovery solution?