Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium


Any way to find if a service is running or not

Posted on 2007-08-11
Medium Priority
Last Modified: 2010-03-05

I want a script to query all machines in a file if a service is running or not.It should pop a box for the service name.

Question by:bsharath
1 Comment
LVL 26

Accepted Solution

Farhan Kazi earned 2000 total points
ID: 19677382
:: ================
:: ================
:: * To run this script you must have domain administrators rights.
:: * This script require "Computers.txt" file on C: drive root from where it will pick computer names.
:: * Copy and Paste following script into notepad and save it with any name having .bat extension.
:: * Successul run will generate 'SrvcStatus.txt' file on C: drive root.
:: Batch Script Start

@Echo Off
SETLOCAL EnableDelayedExpansion
SET /P SrvceName=Enter Service Name:  

IF EXIST C:\SrvcStatus.txt DEL /F /Q C:\SrvcStatus.txt
IF NOT EXIST C:\Computers.txt Goto ShowErr
FOR %%R IN (C:\Computers.txt) Do IF %%~zR EQU 0 Goto ShowErr
FOR /F %%c IN ('Type Computers.txt') Do (
    Echo Processing: %%c
      PING -n 1 -w 1000 %%c|Find /I "TTL" >NUL
      IF NOT ErrorLevel 1 (
            SC \\%%c Query %SrvceName% | Find /I "RUNNING" >NUL
            IF ErrorLevel 1 (Echo !SrvceName! Service is NOT Running on: %%c >>C:\SrvcStatus.txt) Else (
            Echo !SrvceName! Service is Running on: %%c >>C:\SrvcStatus.txt)
      )ELSE (Echo %%c: Not able to connect >>C:\SrvcStatus.txt)

Goto EndScript
Echo "C:\Computers.txt" file does not exist or file is empty!
:: Batch Script End

Featured Post

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Background Information Recently I have fixed file server permission issues for one of my client. The client has 1800 users and one Windows Server 2008 R2 domain joined file server with 12 TB of data, 250+ shared folders and the folder structure i…
Understanding the various editions available is vital when you decide to purchase Windows Server 2012. You need to have a basic understanding of the features and limitations in each edition in order to make a well-informed decision that best suits …
Windows 8 came with a dramatically different user interface known as Metro. Notably missing from that interface was a Start button and Start Menu. Microsoft responded to negative user feedback of the Metro interface, bringing back the Start button a…
With the advent of Windows 10, Microsoft is pushing a Get Windows 10 icon into the notification area (system tray) of qualifying computers. There are many reasons for wanting to remove this icon. This two-part Experts Exchange video Micro Tutorial s…
Suggested Courses

580 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question