Search for a service on all machines in a file or networ/domain

Posted on 2007-07-21
Last Modified: 2010-03-05

I need to Search for a service on all machines in a file or network/domain.

Is there a way to search for a particular service.

Question by:bsharath
    LVL 26

    Accepted Solution

    :: ===============
    :: ===============
    :: * Following script will search for a particular service in machines that are given in Computers.txt file.
    :: * This script require "Computers.txt" file on C: drive root from where it will read computer names.
    :: * You need to set "SrvcName" variables value to the Service name.
    ::    Like:
    ::            SET SrvcName=Messenger
    :: * Successful run will generate "ServiceStatus.txt" file on C: drive root
    :: * Copy and paste following script in notepad and save it with any name having .cmd extension.

    :: *** SCRIPT START ***
    @Echo Off
    SetLocal EnableDelayedExpansion
    SET SrvcName=Messenger

    IF NOT EXIST C:\Computers.txt Goto ShowErr
    FOR %%R IN (C:\Computers.txt) Do IF %%~zR EQU 0 Goto ShowErr
    IF EXIST C:\ServiceStatus.txt DEL /F /Q C:\ServiceStatus.txt

    FOR /F "delims=#" %%c IN (C:\Computers.txt) Do (
          Echo Processing: %%c
          SC \\%%c Query !SrvcName! | Find "!SrvcName!" >NUL
          IF NOT ERRORLEVEL 1 (
                Echo !SrvcName! Found on system: %%c >>C:\ServiceStatus.txt
    Goto EndScript
    Echo "C:\Computers.txt" file does not exist or file is empty!
    :: Batch Script End
    LVL 26

    Expert Comment

    If you want to search all network machines then run following command before you run above script.
    Following command will write all network computer names inside Computers.txt file.

    Start -> Run -> Cmd.exe
    FOR /F "tokens=1" %c IN ('Net view') Do @Echo %c >>C:\Computers.txt

    Featured Post

    Threat Intelligence Starter Resources

    Integrating threat intelligence can be challenging, and not all companies are ready. These resources can help you build awareness and prepare for defense.

    Join & Write a Comment

    This is my 3rd article on SCCM in recent weeks, the 1st ( dealing with installat…
    Remote Apps is a feature in server 2008 which allows users to run applications off Remote Desktop Servers without having to log into them to run the applications.  The user can either have a desktop shortcut installed or go through the web portal to…
    In this video, we discuss why the need for additional vertical screen space has become more important in recent years, namely, due to the transition in the marketplace of 4x3 computer screens to 16x9 and 16x10 screens (so-called widescreen format). …
    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…

    745 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

    Need Help in Real-Time?

    Connect with top rated Experts

    17 Experts available now in Live!

    Get 1:1 Help Now