?
Solved

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

Posted on 2004-08-02
2
Medium Priority
?
222 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
2 Comments
 
LVL 41

Accepted Solution

by:
graye earned 500 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

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

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

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…
Strategic internal linking is often considered an SEO power technique, especially for content marketing. Do you need to hire an SEO agency to optimize you internal linking? No, this article will help you understand the basics of internal linking and…
In a question here at Experts Exchange (https://www.experts-exchange.com/questions/29062564/Adobe-acrobat-reader-DC.html), a member asked how to create a signature in Adobe Acrobat Reader DC (the free Reader product, not the paid, full Acrobat produ…
When cloud platforms entered the scene, users and companies jumped on board to take advantage of the many benefits, like the ability to work and connect with company information from various locations. What many didn't foresee was the increased risk…
Suggested Courses
Course of the Month14 days, 23 hours left to enroll

840 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