?
Solved

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

Posted on 2007-07-21
2
Medium Priority
?
241 Views
Last Modified: 2010-03-05
Hi,

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.

Regards
Sharath
0
Comment
Question by:bsharath
  • 2
2 Comments
 
LVL 26

Accepted Solution

by:
Farhan Kazi earned 2000 total points
ID: 19540789
:: ===============
:: READ THIS FIRST
:: ===============
:: * 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
:ShowErr
Echo "C:\Computers.txt" file does not exist or file is empty!
:EndScript
ENDLOCAL
:: Batch Script End
0
 
LVL 26

Expert Comment

by:Farhan Kazi
ID: 19540808
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
0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Welcome to my series of short tips on migrations. Whilst based on Microsoft migrations the same principles can be applied to any type of migration. My first tip Migration Tip #1 – Source Server Health can be found listed in my profile here: http:…
Welcome to my series of short tips on migrations. Whilst based on Microsoft migrations the same principles can be applied to any type of migration. My first tip Migration Tip #1 – Source Server Health can be found here: http://www.experts-exchang…
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…
Suggested Courses

850 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