Solved

Sugg on service status query & Some batch file help...

Posted on 2004-08-02
2
217 Views
Last Modified: 2010-04-13
1. How to query particualr service status using WMI
here i have the Script for getting all service status ...But I am looking for specific service status...Not all
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
On Error Resume Next
strComputer = "."
Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\cimv2")
Set colItems = objWMIService.ExecQuery("Select * from Win32_Service",,48)
For Each objItem in colItems
    Wscript.Echo "DisplayName: " & objItem.DisplayName
    Wscript.Echo "StartMode: " & objItem.StartMode
    Wscript.Echo "State: " & objItem.State
Next
+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

otherwise I got a output like this....

+++++++++++++++++++++++++++++++++++++++++
DisplayName: Enterprise Security Agent
StartMode: Auto
State: Running
DisplayName: Event Log
StartMode: Auto
State: Running
DisplayName: COM+ Event System
StartMode: Manual
State: Running
DisplayName: Fax Service
StartMode: Manual
State: Stopped
DisplayName: HP ITO Agent
StartMode: Auto
State: Running
DisplayName: IIS Admin Service
StartMode: Auto
State: Running
++++++++++++++++++++++++++++++++++++++++++++

Here i can get the service name using Findstr "DisplayName: IIS Admin Service". but how i can i get the next two line.
If i search for "StartMode: Auto" or "State: Running" it is goign to list all keys.

what i want is like this search for "DisplayName: Enterprise Security Agent"  which is  line 1 and print
the print line2 & line3 which is for Enterprise Security Agent.

then search for "DisplayName: Fax Service" which is "line 10" which is and print
the print line10 & line11 which is for Fax Service

how to do this in batch file.....
0
Comment
Question by:moorthy_kulumani
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 
LVL 41

Accepted Solution

by:
graye earned 125 total points
ID: 11694934
It's about what you'd expect from an SQL style query.... change the line to read:

Set colItems = objWMIService.ExecQuery("Select * from Win32_Service where DisplayName='IIS Admin Service'",,48)
                                                                                                         ^^^^^^^^^^^^^^^^^^^^^^^^^^
0
 
LVL 3

Author Comment

by:moorthy_kulumani
ID: 11701558
Thanks I might need some more help later on with WMI , Exchange , IIS  
0

Featured Post

The Ultimate Checklist to Optimize Your Website

Websites are getting bigger and complicated by the day. Video, images, custom fonts are all great for showcasing your product/service. But the price to pay in terms of reduced page load times and ultimately, decreased sales, can lead to some difficult decisions about what to cut.

Question has a verified solution.

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

NTFS file system has been developed by Microsoft that is widely used by Windows NT operating system and its advanced versions. It is the mostly used over FAT file system as it provides superior features like reliability, security, storage, efficienc…
The conference as a whole was very interesting, although if one has to make a choice between this one and some others, you may want to check out the others.  This conference is aimed mainly at government agencies.  So it addresses the various compli…
Monitoring a network: how to monitor network services and why? Michael Kulchisky, MCSE, MCSA, MCP, VTSP, VSP, CCSP outlines the philosophy behind service monitoring and why a handshake validation is critical in network monitoring. Software utilized …
Do you want to know how to make a graph with Microsoft Access? First, create a query with the data for the chart. Then make a blank form and add a chart control. This video also shows how to change what data is displayed on the graph as well as form…

705 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